Hi ,
I would like to invoke a webservice onfly withou creating the stubs. I am using the axis tool kit.
I am able to invoke the webservice dynamically wthout generating stubs if the service is developed in java.
But when i am trying to invoke the service developed in VB or some thing else i am not able to invoke the
service and getting exception saying that invalid name space.
The code snippet workig fine for the java webservice is
public static void main(String[] args)
{
try{
String ENCODING_STYLE_PROPERTY = "javax.xml.rpc.encodingstyle.namespace.uri";
String NS_XSD = "
http://www.w3.org/2001/XMLSchema";
String BODY_NAMESPACE_VALUE = "
http://localhost:8080/axis/services/Mul";
ServiceFactory factory = ServiceFactory.newInstance();
Service service = factory.createService(new QName("Mul"));
QName port = new QName("Mul");
Call call = service.createCall(port);
call.setTargetEndpointAddress("
http://localhost:8080/axis/services/Mul?wsdl");
call.setProperty(Call.SOAPACTION_USE_PROPERTY, new Boolean(true));
call.setProperty(Call.SOAPACTION_URI_PROPERTY, "");
call.setProperty(ENCODING_STYLE_PROPERTY,"
http://schemas.xmlsoap.org/soap/encoding/");
QName QNAME_TYPE_INT = new QName(NS_XSD, "int");
call.setReturnType(QNAME_TYPE_INT);
call.setOperationName(new QName(BODY_NAMESPACE_VALUE,"multiply"));
call.addParameter("in0", QNAME_TYPE_INT,ParameterMode.IN);
call.addParameter("in1", QNAME_TYPE_INT,ParameterMode.IN);
Integer[] params = new Integer[2];
params[0]=new Integer(2);
params[1]=new Integer(3);
System.out.println(call.invoke(params));
}catch(Exception e){
e.printStackTrace();
}
}
the service wsdl file is
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="
http://172.16.2.71:8080/axis/services/Mul" xmlns="
http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="
http://xml.apache.org/xml-soap" xmlns:impl="
http://172.16.2.71:8080/axis/services/Mul" xmlns:intf="
http://172.16.2.71:8080/axis/services/Mul" 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:message name="multiplyRequest">
<wsdl:part name="in0" type="xsd:int"/>
<wsdl:part name="in1" type="xsd:int"/>
</wsdl:message>
<wsdl:message name="multiplyResponse">
<wsdl:part name="multiplyReturn" type="xsd:int"/>
</wsdl:message>
<wsdl:portType name="Mul">
<wsdl:operation name="multiply" parameterOrder="in0 in1">
<wsdl:input message="impl:multiplyRequest" name="multiplyRequest"/>
<wsdl:output message="impl:multiplyResponse" name="multiplyResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="MulSoapBinding" type="impl:Mul">
<wsdlsoap:binding style="rpc" transport="
http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="multiply">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="multiplyRequest">
<wsdlsoap:body encodingStyle="
http://schemas.xmlsoap.org/soap/encoding/" namespace="
http://172.16.2.71:8080/axis/services/Mul" use="encoded"/>
</wsdl:input>
<wsdl:output name="multiplyResponse">
<wsdlsoap:body encodingStyle="
http://schemas.xmlsoap.org/soap/encoding/" namespace="
http://172.16.2.71:8080/axis/services/Mul" use="encoded"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="Mul">
<wsdl:port binding="impl:MulSoapBinding" name="Mul">
<wsdlsoap:address location="
http://172.16.2.71:8080/axis/services/Mul"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
The code snippet for invoking the VB service is
public static void main(String[] args)
{
try{
String ENCODING_STYLE_PROPERTY = "javax.xml.rpc.encodingstyle.namespace.uri";
String NS_XSD = "
http://www.w3.org/2001/XMLSchema";
String BODY_NAMESPACE_VALUE = "
http://tempuri.org/wsdl/";
ServiceFactory factory = ServiceFactory.newInstance();
Service service = factory.createService(new QName("DNPost"));
QName port = new QName("clsDNMsgSoapPort");
Call call = service.createCall(port);
call.setTargetEndpointAddress("
http://pvinod/DN/DNPost.WSDL");
call.setProperty(Call.SOAPACTION_USE_PROPERTY, new Boolean(true));
call.setProperty(Call.SOAPACTION_URI_PROPERTY, "");
call.setProperty(ENCODING_STYLE_PROPERTY,"
http://schemas.xmlsoap.org/soap/encoding/");
QName QNAME_TYPE_INT = new QName(NS_XSD, "int");
QName QNAME_TYPE_STRING = new QName(NS_XSD, "string");
call.setReturnType(QNAME_TYPE_INT);
call.setOperationName(new QName(BODY_NAMESPACE_VALUE,"UpdateDNStatus"));
call.addParameter("strUserID", QNAME_TYPE_STRING,ParameterMode.IN);
call.addParameter("strPassword", QNAME_TYPE_STRING,ParameterMode.IN);
call.addParameter("strApplicationID", QNAME_TYPE_STRING,ParameterMode.IN);
call.addParameter("strMMSID", QNAME_TYPE_STRING,ParameterMode.IN);
call.addParameter("strDNID", QNAME_TYPE_STRING,ParameterMode.IN);
call.addParameter("strSHORTCODE", QNAME_TYPE_STRING,ParameterMode.IN);
call.addParameter("strStatus", QNAME_TYPE_STRING,ParameterMode.IN);
call.addParameter("strError", QNAME_TYPE_STRING,ParameterMode.INOUT);
String str = new String();
String[] params = { " "," "," "," "," "," "," ",str};
System.out.println(call.invoke(params));
}catch(Exception e){
e.printStackTrace();
}
}
the service wsdl file is
<?xml version='1.0' encoding='UTF-8' ?>
<!-- Generated 04/09/04 by Microsoft SOAP Toolkit WSDL File Generator, Version 1.02.813.0 -->
<definitions name ='DNPost' targetNamespace = '
http://tempuri.org/wsdl/'
xmlns:wsdlns='
http://tempuri.org/wsdl/'
xmlns:typens='
http://tempuri.org/type'
xmlns:soap='
http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:xsd='
http://www.w3.org/2001/XMLSchema'
xmlns:stk='
http://schemas.microsoft.com/soap-toolkit/wsdl-extension'
xmlns='
http://schemas.xmlsoap.org/wsdl/'>
<types>
<schema targetNamespace='
http://tempuri.org/type'
xmlns='
http://www.w3.org/2001/XMLSchema'
xmlns:SOAP-ENC='
http://schemas.xmlsoap.org/soap/encoding/'
xmlns:wsdl='
http://schemas.xmlsoap.org/wsdl/'
elementFormDefault='qualified'>
</schema>
</types>
<message name='clsDNMsg.UpdateDNStatus'>
<part name='strUserID' type='xsd:string'/>
<part name='strPassword' type='xsd:string'/>
<part name='strApplicationID' type='xsd:string'/>
<part name='strMMSID' type='xsd:string'/>
<part name='strDNID' type='xsd:string'/>
<part name='strSHORTCODE' type='xsd:string'/>
<part name='strStatus' type='xsd:string'/>
<part name='strError' type='xsd:string'/>
</message>
<message name='clsDNMsg.UpdateDNStatusResponse'>
<part name='Result' type='xsd:short'/>
<part name='strError' type='xsd:string'/>
</message>
<portType name='clsDNMsgSoapPort'>
<operation name='UpdateDNStatus' parameterOrder='strUserID strPassword strApplicationID strMMSID strDNID strSHORTCODE strStatus strError'>
<input message='wsdlns:clsDNMsg.UpdateDNStatus' />
<output message='wsdlns:clsDNMsg.UpdateDNStatusResponse' />
</operation>
</portType>
<binding name='clsDNMsgSoapBinding' type='wsdlns:clsDNMsgSoapPort' >
<stk:binding preferredEncoding='UTF-8'/>
<soap:binding style='rpc' transport='
http://schemas.xmlsoap.org/soap/http' />
<operation name='UpdateDNStatus' >
<soap:operation soapAction='
http://tempuri.org/action/clsDNMsg.UpdateDNStatus' />
<input>
<soap:body use='encoded' namespace='
http://tempuri.org/message/'
encodingStyle='
http://schemas.xmlsoap.org/soap/encoding/' />
</input>
<output>
<soap:body use='encoded' namespace='
http://tempuri.org/message/'
encodingStyle='
http://schemas.xmlsoap.org/soap/encoding/' />
</output>
</operation>
</binding>
<service name='DNPost' >
<port name='clsDNMsgSoapPort' binding='wsdlns:clsDNMsgSoapBinding' >
<soap:address location='
http://pvinod/DN/DNPost.WSDL' />
</port>
</service>
</definitions>
In this case i am getting the following error
AxisFault
faultCode: {
http://schemas.xmlsoap.org/soap/envelope/}Server
faultString: WSDLReader: The operation requested in the Soap message with soapAction (null) isn't defined in the WSDL file. Thi
s may be because it is in the wrong namespace or has incorrect case
faultActor: null
faultDetail:
errorInfo: <mserror:returnCode>-2147467259</mserror:returnCode><mserror:callStack><mserror:callElement><mserror:component
>WSDLReader</mserror:component><mserror:description>The operation requested in the Soap message with soapAction (null) isn't defi
ned in the WSDL file. This may be because it is in the wrong namespace or has incorrect case</mserror:description><mserror:retur
nCode>-2147467259</mserror:returnCode></mserror:callElement></mserror:callStack>
WSDLReader: The operation requested in the Soap message with soapAction (null) isn't defined in the WSDL file. This may be becau
se it is in the wrong namespace or has incorrect case
at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:135)
at org.apache.axis.encoding.DeserializationContextImpl.endElement(DeserializationContextImpl.java:942)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:559)
at org.apache.xerces.impl.XMLNamespaceBinder.handleEndElement(XMLNamespaceBinder.java:853)
at org.apache.xerces.impl.XMLNamespaceBinder.endElement(XMLNamespaceBinder.java:643)
at org.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(XMLDTDValidator.java:2978)
at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(XMLDTDValidator.java:918)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.handleEndElement(XMLDocumentFragmentScannerImpl.java:1145)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:988)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImp
l.java:1446)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:333)
at org.apache.xerces.parsers.StandardParserConfiguration.parse(StandardParserConfiguration.java:529)
at org.apache.xerces.parsers.StandardParserConfiguration.parse(StandardParserConfiguration.java:585)
at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:147)
at org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1148)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:232)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:546)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:377)
at org.apache.axis.client.Call.invokeEngine(Call.java:2163)
at org.apache.axis.client.Call.invoke(Call.java:2131)
at org.apache.axis.client.Call.invoke(Call.java:1878)
at org.apache.axis.client.Call.invoke(Call.java:1804)
at org.apache.axis.client.Call.invoke(Call.java:1340)
at T1.main(T1.java:72)
please help in solving this
R Sridhar Reddy
Software Engineer ValueLabs
Plot No 1359,
Road No 45,
Jubilee Hills - HYD
rsridhar_at_valuelabs.net tel:
fax:
mobile: 040-23560-0861/2/3
040-2355-3309
9849103458
Signature powered by Plaxo Want a signature like this?
Add me to your address book...