Hi all; i have a session bean as a web service. This is the wsdl file:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://ejbs.websrv.napsi.eng.it"
xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:impl="http://ejbs.websrv.napsi.eng.it"
xmlns:intf="http://ejbs.websrv.napsi.eng.it"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.2beta3
Built on Aug 01, 2004 (05:59:22 PDT)-->
<wsdl:message name="byFamilyCodeResponse">
<wsdl:part name="byFamilyCodeReturn" type="apachesoap:Document"/>
</wsdl:message>
<wsdl:message name="toponomasticResponse">
<wsdl:part name="toponomasticReturn" type="apachesoap:Document"/>
</wsdl:message>
<wsdl:message name="byFiscalCodeResponse">
<wsdl:part name="byFiscalCodeReturn" type="apachesoap:Document"/>
</wsdl:message>
<wsdl:message name="updateRequest">
<wsdl:part name="input" type="apachesoap:Document"/>
</wsdl:message>
<wsdl:message name="byFamilyCodeRequest">
<wsdl:part name="input" type="apachesoap:Document"/>
</wsdl:message>
<wsdl:message name="toponomasticRequest">
<wsdl:part name="input" type="apachesoap:Document"/>
</wsdl:message>
<wsdl:message name="byUserDataRequest">
<wsdl:part name="input" type="apachesoap:Document"/>
</wsdl:message>
<wsdl:message name="byFiscalCodeRequest">
<wsdl:part name="doc" type="apachesoap:Document"/>
</wsdl:message>
<wsdl:message name="byUserDataResponse">
<wsdl:part name="byUserDataReturn" type="apachesoap:Document"/>
</wsdl:message>
<wsdl:message name="updateResponse">
<wsdl:part name="updateReturn" type="apachesoap:Document"/>
</wsdl:message>
<wsdl:portType name="Searcher">
<wsdl:operation name="update" parameterOrder="input">
<wsdl:input message="impl:updateRequest" name="updateRequest"/>
<wsdl:output message="impl:updateResponse" name="updateResponse"/>
</wsdl:operation>
<wsdl:operation name="byFiscalCode" parameterOrder="doc">
<wsdl:input message="impl:byFiscalCodeRequest"
name="byFiscalCodeRequest"/>
<wsdl:output message="impl:byFiscalCodeResponse"
name="byFiscalCodeResponse"/>
</wsdl:operation>
<wsdl:operation name="byUserData" parameterOrder="input">
<wsdl:input message="impl:byUserDataRequest" name="byUserDataRequest"/>
<wsdl:output message="impl:byUserDataResponse"
name="byUserDataResponse"/>
</wsdl:operation>
<wsdl:operation name="byFamilyCode" parameterOrder="input">
<wsdl:input message="impl:byFamilyCodeRequest"
name="byFamilyCodeRequest"/>
<wsdl:output message="impl:byFamilyCodeResponse"
name="byFamilyCodeResponse"/>
</wsdl:operation>
<wsdl:operation name="toponomastic" parameterOrder="input">
<wsdl:input message="impl:toponomasticRequest"
name="toponomasticRequest"/>
<wsdl:output message="impl:toponomasticResponse"
name="toponomasticResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="SearcherSoapBinding" type="impl:Searcher">
<wsdlsoap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="update">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="updateRequest">
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded"/>
</wsdl:input>
<wsdl:output name="updateResponse">
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="byFiscalCode">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="byFiscalCodeRequest">
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded"/>
</wsdl:input>
<wsdl:output name="byFiscalCodeResponse">
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="byUserData">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="byUserDataRequest">
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded"/>
</wsdl:input>
<wsdl:output name="byUserDataResponse">
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="byFamilyCode">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="byFamilyCodeRequest">
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded"/>
</wsdl:input>
<wsdl:output name="byFamilyCodeResponse">
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="toponomastic">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="toponomasticRequest">
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded"/>
</wsdl:input>
<wsdl:output name="toponomasticResponse">
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="SearcherService">
<wsdl:port binding="impl:SearcherSoapBinding" name="Searcher">
<wsdlsoap:address
location="http://localhost:8080/ServicePublisher/services/Searcher"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
I have this client:
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.message.SOAPBodyElement;
import org.apache.axis.message.SOAPBody;
import org.apache.axis.utils.XMLUtils;
import javax.xml.rpc.ServiceException;
import java.util.Vector;
import org.w3c.dom.Document;
import javax.xml.namespace.QName;
import org.apache.log4j.Logger;
import java.net.URL;
import java.net.MalformedURLException;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
/**
* <p>Title: Prototipo Piattaforma PMM piattaforma per la gestione di Web
* Services</p>
*
* <p>Description: Prototipo semplice per la costruzione della piattaforma PMM
* utilizzata per interagire con dei web services.</p>
*
* <p>Copyright: Copyright (c) 2005</p>
*
* <p>Company: Engineering Ingegneria Informatica</p>
*
* @author Angelo Immediata
* @version 1.0
*/
public class SimpleAxisClient {
/**
* Il logger
*/
private static final Logger LOG = Logger.getLogger(SimpleAxisClient.class.
getName());
/**
* Preparo il l'oggetto Call da utilizzare
* @param endpoint String -l'endpoint da utilizzare
* @param operation String -l'operazione da invocare
* @return Call -il Call generato.
* @throws ServiceException -Se ci sono problemi col servizio
*/
private Call getCall(String endpoint, String operation) throws
ServiceException {
if (LOG.isDebugEnabled()) {
LOG.debug("Creating call.....");
}
Call result = (Call) (new Service()).createCall();
try {
result.setTargetEndpointAddress(new URL(endpoint));
} catch (MalformedURLException ex) {
LOG.error(ex);
}
result.setOperation(new QName(endpoint, operation), operation);
if (LOG.isDebugEnabled()) {
LOG.debug("Done!!");
}
return result;
}
/**
* Invoco il web service passandogli il Document generato dalla classe
it.eng.prototype.xml.Parser
* @param doc Document -il Document generato.
* @param endpoint String -l'endpoint del servizio.
* @param operation String -l'operazione da invocare.
* @return Document -il document in uscita al webService
* @throws Exception
*/
public Document getDocument(Document doc, String endpoint,
String operation) throws Exception {
Call call = getCall(endpoint, operation);
Vector result = (Vector) call.invoke(new Object[] {doc});
//Vector result = (Vector) call.invoke(new SOAPBodyElement[] { new
SOAPBodyElement( doc.getDocumentElement() )});
SOAPBodyElement sbe = (SOAPBodyElement) result.get(0);
if (LOG.isDebugEnabled()) {
LOG.debug("Body ricevuto: " +
XMLUtils.DocumentToString(sbe.getAsDocument()));
}
return sbe.getAsDocument();
}
public static void main(String args[]) throws Exception {
SimpleAxisClient client = new SimpleAxisClient();
Call miaCall = client.getCall(
"http://localhost:8082/ServicePublisher/services/Searcher","byFiscalCode");
//it.eng.napsi.util.XMLUtil.stringToDocument( )
DocumentBuilderFactory fac = DocumentBuilderFactory.newInstance();
fac.setValidating(false);
DocumentBuilder builder = fac.newDocumentBuilder(); //
DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = builder.parse(new java.io.ByteArrayInputStream("<?xml
version='1.0' encoding='UTF-8'
standalone='yes'?><ricercaIndividuo><codiceFiscale>MMDNGL74C22H703K</codiceFiscale></ricercaIndividuo>".getBytes()));
/*
Document doc = org.apache.axis.utils.XMLUtils.newDocument();
org.w3c.dom.Element ricercaInd = doc.createElementNS( "pippo",
"byFiscalCode" );
org.w3c.dom.Element codFisc = doc.createElementNS( "pippo",
"codiceFiscale" );
//codFisc.setNodeValue( "MMDNGL74C22H703K" );
ricercaInd.appendChild( codFisc );
codFisc.setNodeValue( "MMDNGL74C22H703K" );
doc.appendChild( ricercaInd );
System.out.println( XMLUtils.DocumentToString( doc ) );
/*
org.w3c.dom.Element elemento =
org.apache.axis.utils.XMLUtils.StringToElement( "pippo", "codiceFiscale",
"MMDNGL74C22H703K" );
org.w3c.dom.Element ric =
org.apache.axis.utils.XMLUtils.StringToElement( "pippo", "ricercaIndividuo", ""
);
doc.importNode(ric, true);
*/
//Document doc = XMLUtils.newDocument(new
java.io.ByteArrayInputStream("<?xml version='1.0' encoding='UTF-8'
standalone='yes'?><ricercaIndividuo><codiceFiscale>MMDNGL74C22H703K</codiceFiscale></ricercaIndividuo>".getBytes()));
org.apache.axis.utils.XMLUtils.StringToElement( "a",
"ricercaIndividuo", "<codiceFiscale>MMDNGL74C22H703K</codiceFiscale>" );
System.out.println("doc.getDocumentElement(): " +
doc.getDocumentElement().getNodeName());
//System.out.println(miaCall.invoke(new SOAPBodyElement[] {new
SOAPBodyElement(new java.io.ByteArrayInputStream("<?xml version='1.0'
encoding='UTF-8'
standalone='yes'?><ricercaIndividuo><codiceFiscale>MMDNGL74C22H703K</codiceFiscale></ricercaIndividuo>".getBytes()))}));
System.out.println(miaCall.invoke(new SOAPBodyElement[] {new
SOAPBodyElement(org.apache.axis.utils.XMLUtils.StringToElement( "a",
"ricercaIndividuo", "<codiceFiscale>MMDNGL74C22H703K</codiceFiscale>" ))}));
}
}
Well when i try this client i have this error:
AxisFault
faultCode: {http://xml.apache.org/axis/}Client
faultSubcode:
faultString: No such operation 'ricercaIndividuo'
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}hostname:PORT-IMMEDIATA
No such operation 'ricercaIndividuo'
at
org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:221)
at
org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:128)
at
org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1083)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown
Source)
at
org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
at
org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:226)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:645)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:424)
at
org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:173)
at org.apache.axis.client.Call.invokeEngine(Call.java:2719)
at org.apache.axis.client.Call.invoke(Call.java:2702)
at org.apache.axis.client.Call.invoke(Call.java:1738)
at
it.eng.test.client.util.SimpleAxisClient.main(SimpleAxisClient.java:130)
Exception in thread "main"
Can anybody tell me why?
Thanks to all.
____________________________________________________________
Navighi a 4 MEGA e i primi 3 mesi sono GRATIS.
Scegli Libero Adsl Flat senza limiti su http://www.libero.it