Hello, I've a little .NET server which adds doubles. The client which uses Apache SOAP 2.2 call the service with two arguments (doubles). The envelop form Apache SOAP looks like this:
<?xml version="1.0" encoding="UTF-8" ?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema"> <SOAP-ENV:Body> <ns1:addNumbers xmlns:ns1="http://tempuri.org/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <dbl1 xsi:type="xsd:double">1.2</dbl1> <dbl2 xsi:type="xsd:double">2.3</dbl2> </ns1:addNumbers> </SOAP-ENV:Body> </SOAP-ENV:Envelope> But .NET doesn't recognize the arguments dbl1 and dbl2. If I change the code a little bit (declaring Parameter) with adding the ns1 the .Net server can read the arguments. <?xml version="1.0" encoding="UTF-8" ?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema"> <SOAP-ENV:Body> <ns1:addNumbers xmlns:ns1="http://tempuri.org/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <ns1:dbl1 xsi:type="xsd:double">1.4</ns1:dbl1> <ns1:dbl2 xsi:type="xsd:double">3.6</ns1:dbl2> </ns1:addNumbers> </SOAP-ENV:Body> </SOAP-ENV:Envelope> the Apache SOAP Code looks like this: package addnumbersclient; import java.io.*; import java.util.*; import java.net.*; import org.w3c.dom.*; import org.apache.soap.util.xml.*; import org.apache.soap.*; import org.apache.soap.encoding.*; import org.apache.soap.encoding.soapenc.*; import org.apache.soap.rpc.*; import org.apache.soap.transport.http.SOAPHTTPConnection; public class AddDoubles { public static void main( String[] args) { System.out.println("calling .NET Service"); URL url = null; try { url = new URL("http://localhost:8080/AddNumbersServer/AddNumbersServer.asmx"); } catch (Exception e) { System.out.println(e); } SOAPMappingRegistry smr = new SOAPMappingRegistry(); StringDeserializer sd = new StringDeserializer(); smr.mapTypes( Constants.NS_URI_SOAP_ENC, new QName("", "Result"), 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 ( Constants.NS_URI_SOAP_ENC); Vector params = new Vector(); params.addElement( new Parameter("ns1:dbl1", Double.class, "1.4", null) ); <-- here I'm adding 'ns1' to the Parameter name params.addElement( new Parameter("ns1:dbl2", Double.class, "3.6", null) ); <-- here I'm adding 'ns1' to the Parameter name 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(".NET Service Response : " + 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() ); } } } What is wrong? I shouldn't specify the namespace 'ns1' because the Toolkit should do that! Maybe there is an mistake in the code? with best regards, Oliver