I am trying to build a simple SOAP Java client consuming a VB.NET Web service. The Web service performs three simple operations. It is working fine.
<WebMethod()> Public Function Hello(ByVal name As String) As String
Hello = "Hello, " + name
End Function
<WebMethod()> Public Function HelloWorld() As String
HelloWorld = "Hello World!"
End Function
<WebMethod()> Public Function addNumbers(ByVal NumberOne As Double, ByVal NumberTwo As Double) As Double
addNumbers = NumberOne + NumberTwo
End Function
But, on the Java client side, the first operation is ok in returning "Hello World!". The other two operation testing is not ok, returning value is not correct.
The following is the source for AddNumbersClient:
class AddNumbersClient
{
public static void main(String[] args) throws Exception
{
URL url = "new" URL ("http://130.140.64.242/AddNumbersWebService/AddNumberService.asmx?op=addNumbers");
SOAPMappingRegistry smr = new SOAPMappingRegistry ();
DoubleDeserializer sd = new DoubleDeserializer ();
smr.mapTypes (Constants.NS_URI_SOAP_ENC,
new QName ("http://tempuri.org", "addNumbersResult"), null, null, sd);
// create the transport and set parameters
SOAPHTTPConnection st = new SOAPHTTPConnection();
// build the call.
Call call = new Call ();
call.setSOAPTransport(st);
call.setSOAPMappingRegistry (smr);
call.setTargetObjectURI ("http://tempuri.org");
call.setMethodName("addNumbers");
call.setEncodingStyleURI ("http://schemas.xmlsoap.org/soap/encoding/");
Vector params = new Vector();
params.addElement(new Parameter("NumberOne", Double.class, "10", Constants.NS_URI_SOAP_ENC));
params.addElement(new Parameter("NumberTwo", Double.class, "25", Constants.NS_URI_SOAP_ENC));
call.setParams(params);
Response resp = null;
try
{
resp = call.invoke (url, "http://tempuri.org/addNumbers");
}
catch (SOAPException e)
{
System.err.println("Caught SOAPException (" +
e.getFaultCode () + "): " +
e.getMessage ());
return;
}
if (resp == null)
{
System.out.println("Response was null");
}
// check response
if (resp != null && !resp.generatedFault())
{
Parameter ret = resp.getReturnValue();
Object value = ret.getValue();
System.out.println ("Answer--> " + value);
}
else {
Fault fault = resp.getFault ();
System.err.println ("Generated fault: ");
System.out.println (" Fault Code = " + fault.getFaultCode());
System.out.println (" Fault String = " + fault.getFaultString());
}
}
}
My guess is the encoding setting is not working on the parameter part.
Can anyone help me? Thanks in advance,
Jingkun
- SOAP Client code using VB/VC Omprakash Bachu
- Re: SOAP Client code using VB/VC Scott Nichol
- Re: SOAP Client code using VB/VC jingkun . hu
- Re: SOAP Client code using VB/VC Scott Nichol
- Re: SOAP Client code using VB/VC jingkun . hu
- Re: SOAP Client code using VB/VC Scott Nichol
- Re: SOAP Client code using VB/VC jingkun . hu
- Re: SOAP Client code using VB/VC Scott Nichol
- CVS for windows? nandkumar rayanker
- Re: SOAP Client code using VB/VC jingkun . hu
- Re: SOAP Client code using VB/VC Scott Nichol
- Re: SOAP Client code using VB/VC jingkun . hu