You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Jim Poulsen <jp...@metamatrix.com> on 2003/05/22 16:00:07 UTC

RE: Question on DII and deserialize

You will probably have to generate a java class from the WSDL description of
the Web Service, and then look at that java class to determine whether or
not it conforms to the java bean specification.

If it does, you can probably use the built in bean deserializer for your
purposes, but you will have to explicitly register the GoogleSearchResult
type with the built in bean deserializer with your Call instance prior to
calling the 'invoke' method.

-----Original Message-----
From: Yang Liu [mailto:liuyang@voxa.com]
Sent: Tuesday, April 22, 2003 7:41 AM
To: axis-user@ws.apache.org
Subject: Question on DII and deserialize


Hi,
I am new to axis and trying to use axis as the client side DII engine.
I played axis for a whole day, but still can't figure out how to do 
certain things, someone please help to see whether I am still on the 
correct road.

When calling webservices with only simple type, everything works fine. 
Then I tried to use DII to call GoogleSearch, my program is very simple:

public class TestGoogleSearch {
     public static void main(String[] args) throws Exception {
         ServiceFactory serviceFac = ServiceFactory.newInstance();
         Service s = serviceFac.createService(new
             URL("http://api.google.com/GoogleSearch.wsdl"),
             new QName("urn:GoogleSearch", "GoogleSearchService"));
         Call c = s.createCall(new QName("urn:GoogleSearch",
             "GoogleSearchPort"),
             new QName("urn:GoogleSearch", "doGoogleSearch"));
         Object ret = c.invoke(
             new Object[]{"i6Cu0fZQFHILEiqcBJDXAshfuTxmjN7r",
                 "axis", new Integer(1), new Integer(10),
                 Boolean.FALSE, "", Boolean.TRUE, "", "", ""
             });
     }
}

Then get exception as:

- Exception:
org.xml.sax.SAXException: Deserializing parameter 'return':  could not 
find deserializer for type {urn:GoogleSearch}GoogleSearchResult
	at
org.apache.axis.message.RPCHandler.onStartChild(RPCHandler.java:302)
	at 
org.apache.axis.encoding.DeserializationContextImpl.startElement(Deserializa
tionContextImpl.java:963)
	at 
org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:198)
	at 
org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:
722)
	at
org.apache.axis.message.RPCElement.deserialize(RPCElement.java:233)
	at org.apache.axis.message.RPCElement.getParams(RPCElement.java:347)
	at org.apache.axis.client.Call.invoke(Call.java:2234)
	at org.apache.axis.client.Call.invoke(Call.java:2133)
	at org.apache.axis.client.Call.invoke(Call.java:1656)
	at com.voxa.test.TestGoogleSearch.main(TestGoogleSearch.java:39)
.......



I understand that axis tries to find a deserializer to deserialize the 
response into a java object. But I only need axis to return me an 
object, that it can be a dom element or SOAPElement, whatever. I only 
need to be able to access the information in the returned object.

So I guess I need register some special deserializer, and I don't know 
where to begin. The javax.xml.rpc package has some TypeMapping interface 
and deserializer interface, but with little documentation. I read some 
of axis code, guess that I should implement a DeserializerImpl, and do 
my own stuff.

Am I on the correct road? Is there an existing deserializer doing the 
same stuff? If I want to use this approach, do I need to register a 
deserializer for each XML type I met? Is there a way I register once 
then handle all those complex XML type (but still let axis handle simple 
type)?

Thanks in advance.

yang