Hi
All,
I
would like to have some
clarifications on usage of complex-types used as parameters/return
types in WebServices :
Consider 3 user-defined type as follows :
public class Address {
private String state;
private int zip;
public void setState (String state) {
this.state = state;
}
public String getState () {
return state;
}
public void setZip (int zip) {
this.zip = zip;
}
public int getZip () {
return zip;
}
}
public class SimpleRequest {
private int orderId;
private String orderName;
public int getOrderId () {
return orderId;
}
public void setOrderId (int orderId) {
this.orderId = orderId;
}
public String getOrderName()
{
return orderName;
}
public void setOrderName(String orderName)
{
this.orderName = orderName;
}
}
public class ComplexRequest {
private int orderId;
private Address[] allAddresses;
public int getOrderId () {
return orderId;
}
public void setOrderId (int orderId) {
this.orderId = orderId;
}
public Address[] getAllAddresses()
{
return allAddresses;
}
public void setAllAddresses(Address[] allAddresses)
{
this.allAddresses = allAddresses;
}
}
let's have 2 webService methods :
public boolean simpleOrder (SimpleRequest sRequest) throws
java.rmi.RemoteException;
public boolean complexOrder (ComplexRequest
cRequest) throws java.rmi.RemoteException;
On the client side, I instantiate and fill various required fields for
both SimpleRequest and ComplexRequest objects :
1. While calling simpleOrder method, everything succeds
2. While calling complexOrder method, I get following exception :
serialization error: java.lang.IllegalArgumentException: object is
not an instance of declaring class
serialization error: java.lang.IllegalArgumentException: object is not
an instance of declaring class
at
com.sun.xml.rpc.encoding.ObjectSerializerBase.serialize(ObjectSerializerBase.java
:113)
at
com.sun.xml.rpc.encoding.ReferenceableSerializerImpl.serializeInstance(Referencea
bleSerializerImpl.java:194)
at
com.sun.xml.rpc.encoding.SOAPSerializationContext.serializeMultiRefObjects(SOAPSe
rializationContext.java:94)
at
com.sun.xml.rpc.client.StreamingSender._writeRequest(StreamingSender.java:477)
at
com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:59)
at
com.sun.xml.rpc.client.dii.CallInvokerImpl.doInvoke(CallInvokerImpl.java:61)
at
com.sun.xml.rpc.client.dii.BasicCall.invoke(BasicCall.java:353)
at
com.sun.xml.rpc.client.dii.CallInvocationHandler.doCall(CallInvocationHandler.jav
a:99)
at
com.sun.xml.rpc.client.dii.CallInvocationHandler.invoke(CallInvocationHandler.jav
a:71)
at $Proxy0.order(Unknown Source)
at FogWSDynClient.main(FogWSDynClient.java:154)
It is to be noted that the exception comes at the time when we make a
call to the web service method i.e.
//Create and fill an Array of Address objects
Address[] testAddresses;
cRequest.setAllAddresses(testAddresses);
//No compilation or Runtime error
try {
boolean response = wsProxy.complexOrder (cRequest); //Throws Exception
} catch (Exception exc)
{
...
}
If we inverse the situation i.e. we expect a similar complex type in
Response I get Deserialization Error as follows :
deserialization error: deserialization error: no deserializer is
registered for ({urn:Address}Address, {1})
deserialization error: deserialization error: no deserializer is
registered for ({urn:Address}Address, {1})
at
com.sun.xml.rpc.encoding.SOAPDeserializationContext.deserializeMultiRefObjects(SO
APDeserializationContext.java:82)
at
com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:163)
at
com.sun.xml.rpc.client.dii.CallInvokerImpl.doInvoke(CallInvokerImpl.java:61)
at
com.sun.xml.rpc.client.dii.BasicCall.invoke(BasicCall.java:353)
at
com.sun.xml.rpc.client.dii.CallInvocationHandler.doCall(CallInvocationHandler.java:99)
at
com.sun.xml.rpc.client.dii.CallInvocationHandler.invoke(CallInvocationHandler.java:71)
at $Proxy0.offerInfo(Unknown Source)
at FogWSDynClient.main(FogWSDynClient.java:99)
Another
strange thing is that if we pass a null object in place of Array of
Address objects, call to WebService succeeds. My doubt is that when
there is a user-defined type which has only primitive type as its
attributes, deserialization and serialization works fine but in case
when a
user-defined type in turn contains another user-defined type it is
not able to figure out the serialization/deserialization mechanism for
encapsulated complextypes ?
I
have tried implementing the client using DynamicProxy method as well as
DII method but no success. What can be the cause of this error? Any
suggestions /ideas ? I don't want to use the Static stub implementation
as that way bounds us to a specific implementation.
I have general questions related to Serializers/Deserializers :
1 When
we decide to expose a user defined type in web service either as
parameter or return type and we implement it as JavaBean (as specified
in Jax-RPC 1.1 specifications chapter 5) will it be enough to do on the
server side or we have to do it some other work as well ? In other
words whether it is client or WebService which is
responsible for specifying or implementing Serializers and
Deserializers for exposed user defined complex types.
2. Can we explicilty specify Serializers/Deserialzers for a particular
user-defined type on client side? if yes, can you please point me to
the relevant documentation.
3 If a user defined type must implement
java.io.Serializable interface as well even if it is implemented as
JavaBean in order
to be passed as parameter/return type successfully in a Web Service ?
Finally a WSDL related question, are there any differences in WSDL
files generated for the same implementation by different tools example
between ApacheAxis and JWSDP ?
Are there any interoperability issues between WebService developed
using Axis API and client developed using JWSDP ?
Sorry it was a bit long.
Regards
Narinder
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@jax-rpc.dev.java.net
For additional commands, e-mail: users-help@jax-rpc.dev.java.net