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?