By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,953 Members | 1,161 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,953 IT Pros & Developers. It's quick & easy.

Serializers ????

P: n/a
I'm trying to call a web service I created in .NET from a Java client using
Apache SOAP but I can't seem to read the response back from the webservice
even though, it's just sending back a String !!!

It's a basic HelloWorld webservice and the Java client definitely calls it
because I added a database update inside the webservice to make sure that it
was called.

The client keeps complaining that it can't find a deserializer to handle the
result.
Any ideas on what deserializer I should use ?

Client Code :

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 HelloWorldTest {

public static void main(String[] args) throws Exception {

URL url = new URL ("http://myServer/HelloWorld/Hello.asmx");
String WS_targetURI = "http://tempuri.org/HelloWorld/Hello";
String WS_method = "HelloWorld";

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 (WS_targetURI);
call.setMethodName(WS_method);
call.setEncodingStyleURI ("http://schemas.xmlsoap.org/soap/encoding/");

Vector params = new Vector();
//params.addElement(new Parameter("arg0", String.class, "KLAX", null));
call.setParams(params);

Response resp = null;
try {
resp = call.invoke (url, WS_targetURI + "/" + WS_method);
}
catch (SOAPException e) {
System.err.println("Caught SOAPException (" + e.getFaultCode () + "): " +
e.getMessage ());
return;
}

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());
}
}
}

WSDL for webservice :

<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:s0="http://tempuri.org/HelloWorld/Hello"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
targetNamespace="http://tempuri.org/HelloWorld/Hello"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
<s:schema elementFormDefault="qualified"
targetNamespace="http://tempuri.org/HelloWorld/Hello">
<s:element name="HelloWorld">
<s:complexType />
</s:element>
<s:element name="HelloWorldResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="HelloWorldResult"
type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="myTest">
<s:complexType />
</s:element>
<s:element name="myTestResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="myTestResult"
type="s0:ArrayOfString" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="ArrayOfString">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="string"
nillable="true" type="s:string" />
</s:sequence>
</s:complexType>
<s:element name="string" nillable="true" type="s:string" />
<s:element name="ArrayOfString" nillable="true"
type="s0:ArrayOfString" />
</s:schema>
</types>
<message name="HelloWorldSoapIn">
<part name="parameters" element="s0:HelloWorld" />
</message>
<message name="HelloWorldSoapOut">
<part name="parameters" element="s0:HelloWorldResponse" />
</message>
<message name="myTestSoapIn">
<part name="parameters" element="s0:myTest" />
</message>
<message name="myTestSoapOut">
<part name="parameters" element="s0:myTestResponse" />
</message>
<message name="HelloWorldHttpGetIn" />
<message name="HelloWorldHttpGetOut">
<part name="Body" element="s0:string" />
</message>
<message name="myTestHttpGetIn" />
<message name="myTestHttpGetOut">
<part name="Body" element="s0:ArrayOfString" />
</message>
<message name="HelloWorldHttpPostIn" />
<message name="HelloWorldHttpPostOut">
<part name="Body" element="s0:string" />
</message>
<message name="myTestHttpPostIn" />
<message name="myTestHttpPostOut">
<part name="Body" element="s0:ArrayOfString" />
</message>
<portType name="HelloSoap">
<operation name="HelloWorld">
<documentation>Test HelloWorld webservice (Dave Swift
10-03-04)</documentation>
<input message="s0:HelloWorldSoapIn" />
<output message="s0:HelloWorldSoapOut" />
</operation>
<operation name="myTest">
<documentation>test passing back an array)</documentation>
<input message="s0:myTestSoapIn" />
<output message="s0:myTestSoapOut" />
</operation>
</portType>
<portType name="HelloHttpGet">
<operation name="HelloWorld">
<documentation>Test HelloWorld webservice (Dave Swift
10-03-04)</documentation>
<input message="s0:HelloWorldHttpGetIn" />
<output message="s0:HelloWorldHttpGetOut" />
</operation>
<operation name="myTest">
<documentation>test passing back an array)</documentation>
<input message="s0:myTestHttpGetIn" />
<output message="s0:myTestHttpGetOut" />
</operation>
</portType>
<portType name="HelloHttpPost">
<operation name="HelloWorld">
<documentation>Test HelloWorld webservice (Dave Swift
10-03-04)</documentation>
<input message="s0:HelloWorldHttpPostIn" />
<output message="s0:HelloWorldHttpPostOut" />
</operation>
<operation name="myTest">
<documentation>test passing back an array)</documentation>
<input message="s0:myTestHttpPostIn" />
<output message="s0:myTestHttpPostOut" />
</operation>
</portType>
<binding name="HelloSoap" type="s0:HelloSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document" />
<operation name="HelloWorld">
<soap:operation
soapAction="http://tempuri.org/HelloWorld/Hello/HelloWorld" style="document"
/>
<input>
<soap:body use="literal" />
</input>
<output>
<soap:body use="literal" />
</output>
</operation>
<operation name="myTest">
<soap:operation
soapAction="http://tempuri.org/HelloWorld/Hello/myTest" style="document" />
<input>
<soap:body use="literal" />
</input>
<output>
<soap:body use="literal" />
</output>
</operation>
</binding>
<binding name="HelloHttpGet" type="s0:HelloHttpGet">
<http:binding verb="GET" />
<operation name="HelloWorld">
<http:operation location="/HelloWorld" />
<input>
<http:urlEncoded />
</input>
<output>
<mime:mimeXml part="Body" />
</output>
</operation>
<operation name="myTest">
<http:operation location="/myTest" />
<input>
<http:urlEncoded />
</input>
<output>
<mime:mimeXml part="Body" />
</output>
</operation>
</binding>
<binding name="HelloHttpPost" type="s0:HelloHttpPost">
<http:binding verb="POST" />
<operation name="HelloWorld">
<http:operation location="/HelloWorld" />
<input>
<mime:content type="application/x-www-form-urlencoded" />
</input>
<output>
<mime:mimeXml part="Body" />
</output>
</operation>
<operation name="myTest">
<http:operation location="/myTest" />
<input>
<mime:content type="application/x-www-form-urlencoded" />
</input>
<output>
<mime:mimeXml part="Body" />
</output>
</operation>
</binding>
<service name="Hello">
<port name="HelloSoap" binding="s0:HelloSoap">
<soap:address location="http://myServer/HelloWorld/Hello.asmx" />
</port>
<port name="HelloHttpGet" binding="s0:HelloHttpGet">
<http:address location="http://myServer/HelloWorld/Hello.asmx" />
</port>
<port name="HelloHttpPost" binding="s0:HelloHttpPost">
<http:address location="http://myServer/HelloWorld/Hello.asmx" />
</port>
</service>
</definitions>
Jul 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.