This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Web Services and the fly likes dii client returning custom types Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "dii client returning custom types" Watch "dii client returning custom types" New topic
Author

dii client returning custom types

Catalin Barcau
Greenhorn

Joined: May 14, 2004
Posts: 6
i have problems with a web service dii client, accesing a function. the function returns a custom type (a class with a string and an Integer). I was curios what the problem might be?

(the function returns an object from a class named DataHolder, consisting of an Integer and a String. no parametres are required to call the function.)

seems that the namespace is wrong...have no idea how ever what to do; what i am supposed to do in order to have the namespace deployed as an url? what to do to actually get the object..it is composed of simple types...shoul i write a deserialier in this case? what to do in general; when returning what thet call a "value type"?

here is the code:

package websrv2;

import java.util.*;
import javax.rmi.PortableRemoteObject;
import javax.xml.rpc.Call;
import javax.xml.rpc.Service;
import javax.xml.rpc.JAXRPCException;
import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceFactory;
import javax.xml.rpc.ParameterMode;
import java.rmi.RemoteException;
import javax.xml.rpc.Stub;


public class TestClient {


private static String qnameService = "TestWebServiceClass";
private static String qnamePort = "TestWebServiceIntf";

private static String BODY_NAMESPACE_VALUE =
"TestNamespaceClass";
private static String ENCODING_STYLE_PROPERTY =
"javax.xml.rpc.encodingstyle.namespace.uri";
private static String NS_XSD = "http://www.w3.org/2001/XMLSchema";
private static String URI_ENCODING =
"http://schemas.xmlsoap.org/soap/encoding/";
public static void main(String[] args) throws RemoteException
{

System.out.println("Endpoint address = http://192.168.0.5:8080/class-web/web");

try
{
ServiceFactory factory = ServiceFactory.newInstance();
Service service = factory.createService(new QName(qnameService));
System.out.println("1");
QName port = new QName(qnamePort);

Call call = service.createCall(port);
call.setTargetEndpointAddress("http://192.168.0.5:8080/class-web/web");
System.out.println("2");
call.setProperty(Call.SOAPACTION_USE_PROPERTY, new Boolean(true));
System.out.println("3");
call.setProperty(Call.SOAPACTION_URI_PROPERTY, "");
System.out.println("4");
call.setProperty(ENCODING_STYLE_PROPERTY, URI_ENCODING);

QName QNAME_TYPE_CPLX_TYPE = new QName(BODY_NAMESPACE_VALUE, "DataHolder");

call.setReturnType(QNAME_TYPE_CPLX_TYPE);
call.setOperationName(new QName(BODY_NAMESPACE_VALUE,"show"));

DataHolder dh = (DataHolder)call.invoke(null);
System.out.println("5!");
}
catch (Exception ex)
{
ex.printStackTrace();
System.exit(1);
}
}
}

here is the error:

deserialization error: java.lang.NullPointerException
at com.sun.xml.rpc.encoding.ObjectSerializerBase.deserialize(ObjectSeria
lizerBase.java:214)
at com.sun.xml.rpc.encoding.ReferenceableSerializerImpl.deserialize(Refe
renceableSerializerImpl.java:134)
at com.sun.xml.rpc.client.dii.CallInvokerImpl._readFirstBodyElement(Call
InvokerImpl.java:222)
at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:158
)
at com.sun.xml.rpc.client.dii.CallInvokerImpl.doInvoke(CallInvokerImpl.j
ava:61)
at com.sun.xml.rpc.client.dii.BasicCall.invoke(BasicCall.java:446)
at websrv2.TestClient.main(TestClient.java:56)

CAUSE:

java.lang.NullPointerException
at com.sun.xml.rpc.encoding.soap.SOAPResponseSerializer.doDeserialize(SO
APResponseSerializer.java:149)
at com.sun.xml.rpc.encoding.ObjectSerializerBase.deserialize(ObjectSeria
lizerBase.java:167)
at com.sun.xml.rpc.encoding.ReferenceableSerializerImpl.deserialize(Refe
renceableSerializerImpl.java:134)
at com.sun.xml.rpc.client.dii.CallInvokerImpl._readFirstBodyElement(Call
InvokerImpl.java:222)
at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:158
)
at com.sun.xml.rpc.client.dii.CallInvokerImpl.doInvoke(CallInvokerImpl.j
ava:61)
at com.sun.xml.rpc.client.dii.BasicCall.invoke(BasicCall.java:446)
at websrv2.TestClient.main(TestClient.java:56)

CAUSE:

java.lang.NullPointerException
at com.sun.xml.rpc.encoding.soap.SOAPResponseSerializer.doDeserialize(SO
APResponseSerializer.java:149)
at com.sun.xml.rpc.encoding.ObjectSerializerBase.deserialize(ObjectSeria
lizerBase.java:167)
at com.sun.xml.rpc.encoding.ReferenceableSerializerImpl.deserialize(Refe
renceableSerializerImpl.java:134)
at com.sun.xml.rpc.client.dii.CallInvokerImpl._readFirstBodyElement(Call
InvokerImpl.java:222)
at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:158
)
at com.sun.xml.rpc.client.dii.CallInvokerImpl.doInvoke(CallInvokerImpl.j
ava:61)
at com.sun.xml.rpc.client.dii.BasicCall.invoke(BasicCall.java:446)
at websrv2.TestClient.main(TestClient.java:56)

can anybody help?
Catalin Barcau
Greenhorn

Joined: May 14, 2004
Posts: 6
forgot the wsdl for the web service...
here it is:
<?xml version="1.0" encoding="UTF-8" ?>
- <definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="TestNamespaceClass" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" name="TestWebServiceClass" targetNamespace="TestNamespaceClass">
- <types>
- <schema xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="TestNamespaceClass">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
- <complexType name="DataHolder">
- <sequence>
<element name="intg" type="soap11-enc:int" />
<element name="str" type="string" />
</sequence>
</complexType>
</schema>
</types>
<message name="TestWebServiceIntf_show" />
- <message name="TestWebServiceIntf_showResponse">
<part name="result" type="tns ataHolder" />
</message>
- <portType name="TestWebServiceIntf">
- <operation name="show">
<input message="tns:TestWebServiceIntf_show" />
<output message="tns:TestWebServiceIntf_showResponse" />
</operation>
</portType>
- <binding name="TestWebServiceIntfBinding" type="tns:TestWebServiceIntf">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc" />
- <operation name="show">
<soap peration soapAction="" />
- <input>
<soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded" namespace="TestNamespaceClass" />
</input>
- <output>
<soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded" namespace="TestNamespaceClass" />
</output>
</operation>
</binding>
- <service name="TestWebServiceClass">
- <port name="TestWebServiceIntfPort" binding="tns:TestWebServiceIntfBinding">
<soap:address location="http://warlord:8080/class-web/web" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" />
</port>
</service>
</definitions>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: dii client returning custom types
 
Similar Threads
Error while Calling createService in DII Client
unexpected encoding style: jax rpc dii error
ClassCastException for SOAP message
dii client problems..help!
deserialization error: XML reader error: unexpected character content: "<?xml version='1.0' ?>