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 Donald Chen <wx...@yahoo.com> on 2004/08/13 21:20:18 UTC

How to deseralize a hashtable?

Hi, All.

I have a WS in Perl via SOAP::Lite.  Via this WS, a client can call a method getAllInfo() which
returns a
Hashtable.  I wrote a WS client in perl and a client in Apache-Soap-2.3.1 which works, but writing
a WS client in Apache-Axis-1.1 seems not that lucky.

Specifically, the error I got is like this:

- Exception:
org.xml.sax.SAXException: Deserializing parameter 's-gensym12':  could not find deserializer for
type {http://xml.apache.org/xml-soap}SOAPStruct
        at org.apache.axis.message.RPCHandler.onStartChild(RPCHandler.java:302)
        at
org.apache.axis.encoding.DeserializationContextImpl.startElement(DeserializationContextImpl.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:323)
        at org.apache.axis.message.RPCElement.getParams(RPCElement.java:347)
        at org.apache.axis.client.Call.invoke(Call.java:2272)
        at org.apache.axis.client.Call.invoke(Call.java:2171)
        at org.apache.axis.client.Call.invoke(Call.java:1691)
        at samples.userguide.example1.GetChemDef.main(GetChemDef.java:21)
org.xml.sax.SAXException: Deserializing parameter 's-gensym12':  could not find deserializer for
type {http://xml.apache.org/xml-soap}SOAPStruct


Here is the payload I got from the server:

<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope
xmlns:namesp2="http://xml.apache.org/xml-soap"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"><SOAP-ENV:Body><namesp17:getAllInfoResponse
xmlns:namesp17="http://localhost:89005/ChemDefServices"><s-gensym68
xsi:type="namesp2:SOAPStruct"><delimilator xsi:type="xsd:string">|</delimilator><chemistry
xsi:type="xsd:string">caffeine</chemistry><a xsi:type="xsd:string">aPiece</a><smiles
xsi:type="xsd:string">c1ccccc1</smiles><b xsi:type="xsd:string">bPiece</b><syntaxOk
xsi:type="xsd:int">1</syntaxOk></s-gensym68></namesp17:getAllInfoResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>


This payload refects a hashtable:

%h = ( chemistry => 'caffeine',
           a             => 'aPiece',
           b             => 'bPiece',
           smiles     => 'c1ccccc1'
         );

Here are the major code lines (as you can see, I was trying to use the HashtableSerializer ):

package samples.userguide.example1;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import javax.xml.namespace.QName;

public class GetChemDef {
   public static void main(String [] args) {
       String ret = "1";
       try {
           String endpoint =  "http://jlocalhost:9005/chemDefDaemon3";

           Service  service = new Service();
           Call     call    = (Call) service.createCall();

           call.setTargetEndpointAddress( new java.net.URL(endpoint) );
           call.setOperationName(new QName("urn:ChemDefServices", "getAllInfo"));
           call.setUseSOAPAction(true);
           call.setSOAPActionURI("urn:ChemDefServices#getAllInfo");
           ret = (String) call.invoke( new Object[] { args[0] } );

           System.out.println("Sent " + args[0] + ", got '" + ret + "'");
       } catch (Exception e) {
           System.err.println(e.toString());
       }
   }
}

Did I miss something to make it work?  Do I need to write my own deseralizer for the hashtable? 
If yes, how to incorporate the deseralizer to the main funciton?

Thanks in advance,

Donald            


		
__________________________________
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail