aspose file tools*
The moose likes Web Services and the fly likes JWSDP, DII Client and method returning complex type(edit) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "JWSDP, DII Client and method returning complex type(edit)" Watch "JWSDP, DII Client and method returning complex type(edit)" New topic
Author

JWSDP, DII Client and method returning complex type(edit)

Yann Emeraud
Greenhorn

Joined: May 03, 2004
Posts: 15
Hi,
I read the The Java Web Service Tutorial Chapter 12
I wrote a static client stub calling remote methods returning various object (Integer, String, Vector...).
It worked fine.
Then i tried to do the same thing with a DDI client.
When i call a method returning an String or Integer type object, everything are ok.
But when i call a method returning a Vector type object,i get this error message:
deserialization error: java.lang.NullPointerException
Do you see where i am wrong?
Here a small portion of my DII client:

Portion of the target WSDL file:

Thank your for your help
[ May 05, 2004: Message edited by: Yann Emeraud ]
Yann Emeraud
Greenhorn

Joined: May 03, 2004
Posts: 15
I saw a post that might explain my problem in java forum
They say that if you want to call a remote method returning complex type you have to write yourself a "deserializer".
But what is a deserializer?
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by Yann Emeraud:
But what is a deserializer?
A deserializer is a class that knows how to deserialize a certain type of XML tree into a Java object. A serializer is the counterpart which knows how to serialize a certain type of Java object into XML.
Web services engines provide built-in de/serializers for the basic data types such as Integer and String, and some collection classes as well, but if your particular return type (or parameter type) is not one of those, you need to write your own (and the way you do this is dependent on your particular web services engine).


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Yann Emeraud
Greenhorn

Joined: May 03, 2004
Posts: 15
Thanks you for the hint Lasse Koskela.
I found what i m doing wrong on the above example.
I didn't set the right namespace in the DIIClient QName QNAME_TYPE_VECTOR.
In the shema making reference to Vector type in the WSDL file we can see:


But in my DII client source i set the targetNamespace like this:

To make the above example work, i simply have to change it to:

Unlike what i was saying, JAXRPC does support complex types (Vector, Array, and so on), as written in the Java Web Services Tutorial Chapter 12 (Types Supported By JAX-RPC)
[ May 05, 2004: Message edited by: Yann Emeraud ]
Catalin Barcau
Greenhorn

Joined: May 14, 2004
Posts: 6
hi!
I am trying to develop a dii client to return a complex type (in fact a custom type). the function should return an object of a class defined by me
(DataHolder - consisting of an Integer and a string), and i am having a lot of trouble with that. can you please provide some help?

this is the config.xml file that i have written for the web service. should i change anything in it?

<?xml version="1.0" encoding="UTF-8"?>
<configuration
xmlns="http://java.sun.com/xml/ns/jax-rpc/ri/config">
<service
name="TestWebServiceClass"
targetNamespace="http://192.168.0.5:8080/class-web/web"
typeNamespace="http://192.168.0.5:8080/class-web/web"
packageName="websrv2">
<interface name="websrv2.TestWebServiceIntf"/>
</service>
</configuration>

thanks a lot!
Yann Emeraud
Greenhorn

Joined: May 03, 2004
Posts: 15
Catalin, if you want to use your custom Complex Type you should use Axis (see Chapter Interoperating with "untyped" servers and Encoding Your Beans - the BeanSerialize) (an implementation of JAX-RPC).

It provides a bean (de)serializer that will let you use your DataHolder easily.

You'll just have to add a line in your client and in your deploy.wsdd (axis's Example 5).

P.S: your DataHolder must map the javaBean schema (one setter and getter for each field, a constructor with no argument, ...)
Nagendra E Loli
Greenhorn

Joined: Feb 23, 2009
Posts: 12
Lasse Koskela wrote:
Originally posted by Yann Emeraud:
But what is a deserializer?
A deserializer is a class that knows how to deserialize a certain type of XML tree into a Java object. A serializer is the counterpart which knows how to serialize a certain type of Java object into XML.
Web services engines provide built-in de/serializers for the basic data types such as Integer and String, and some collection classes as well, but if your particular return type (or parameter type) is not one of those, you need to write your own (and the way you do this is dependent on your particular web services engine).


Hi Sheriff,

I am facing the Deserializer error in my Web service.. Can you send me the sample code to do Serealize & Deserialize..

If you send me the Code it helps me a lot.. Please help me..

My Web Service java classes are as below..

CPServices.java

public class CPServices implements Serializable
{

public void smsMo(java.lang.String service_id, java.lang.String source_mobtel,
java.lang.String sub_id, java.lang.String keyword, java.lang.String transaction_id,
java.lang.String short_code_suffix_ind, java.lang.String short_code_suffix, SMSContent[]
sms_contents)
{

}

}


SMSConetent.java


public class SMSContent implements Serializable
{
public java.lang.String content;

public java.lang.String ucp_data_coding_id;

public java.lang.String ucp_msg_class;

public java.lang.String ucp_msg_type;

public SMSContent()
{
System.out.println("--------Inside SMSContent() Constructor-----------");
}

public SMSContent(java.lang.String content, java.lang.String ucp_data_coding_id,
java.lang.String ucp_msg_class, java.lang.String ucp_msg_type)
{
if (content == null)
{
throw new IllegalArgumentException("Content is null!");
}

if (ucp_data_coding_id == null)
{
throw new IllegalArgumentException("ucp_data_coding_id is null!");
}

if (ucp_msg_class == null)
{
throw new IllegalArgumentException("ucp_msg_class is null!");
}

if (ucp_msg_type == null)
{
throw new IllegalArgumentException("ucp_msg_type is null!");
}
this.content = content;
this.ucp_data_coding_id = ucp_data_coding_id;
this.ucp_msg_class = ucp_msg_class;
this.ucp_msg_type = ucp_msg_type;
}

public String getContent() {
return content;
}

public void setContent(java.lang.String content) {
this.content = content;
}

public java.lang.String getUcp_data_coding_id() {
return ucp_data_coding_id;
}

public void setUcp_data_coding_id(java.lang.String ucp_data_coding_id) {
this.ucp_data_coding_id = ucp_data_coding_id;
}

public java.lang.String getUcp_msg_class() {
return ucp_msg_class;
}

public void setUcp_msg_class(java.lang.String ucp_msg_class) {
this.ucp_msg_class = ucp_msg_class;
}

public java.lang.String getUcp_msg_type() {
return ucp_msg_type;
}

public void setUcp_msg_type(java.lang.String ucp_msg_type) {
this.ucp_msg_type = ucp_msg_type;
}

/**
* Test for equality.
* @param object any object
* @return true if parameters are equal
*/
public boolean equals(Object object)
{
if ((object instanceof SMSContent))
{
SMSContent secondSMSC = (SMSContent) object;

return secondSMSC.content.equals(secondSMSC.content) &&
secondSMSC.ucp_data_coding_id.equals(secondSMSC.ucp_data_coding_id) &&
secondSMSC.ucp_msg_class.equals(secondSMSC.ucp_msg_class) &&
secondSMSC.ucp_msg_type.equals(secondSMSC.ucp_msg_type);
}
return false;

}

}




When i call the smsMo() from the WebService i am getting below error:

- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <soapenv:Body>
- <soapenv:Fault>
<faultcode>soapenv:Server.userException</faultcode>
<faultstring>org.xml.sax.SAXException: No deserializer for {http://DefaultNamespace}SMSContent</faultstring>
- <detail>
<ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">sfjdev</ns1:hostname>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>

Canu please help me regarding this how to get the Deserializer for this..


Thanks in advance....
 
Don't get me started about those stupid light bulbs.
 
subject: JWSDP, DII Client and method returning complex type(edit)
 
Similar Threads
Encoding style not supported
dii client problems..help!
Error while Calling createService in DII Client
How do I return simple object via web services
Running a DII client through JSP