• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

dii client returning custom types

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
It wasn't my idea to go to some crazy nightclub in the middle of nowhere. I just wanted to stay home and cuddle with this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic