Hello, I am attempting to pass a Hashtable from a Perl client using SOAP::Lite to a Java servlet using Apache Soap, running on the Tomcat 4.0 platform. The intent of the design is to have an extensible input variable that represents one or more key/value pairs. Method overloading seems non-optimal for this design, as follows:
CreateThing (string phone, string name) CreateThing (string phone, string address) CreateThing (string phone, string name, string address) CreateThing (string phone, string zip, string name) CreateThing (string phone, string name, string fax, string address) ...etc. Instead, I want to have a method as follows: CreateThing(Hashtable stuff) I wouldn't be writing if this was working. What follows are five very small XML files. It should be noted that Java -> Java Soap is working very well using the Hashtable structure. I would like to know how to either have SOAP::Lite produce the required XML, or for Apache Soap to be able to handle this structure. The first one represents the XML produced by a Java client using Apache Soap, talking to a Java server using Apache Soap. The other four are attempts to build the required data structure using SOAP::Lite from Perl. Each file includes a comment indicating the relevant code that produced the XML. ------------------------------------------------------------------------- XML from Java -> Java: this works ------------------------------------------------------------------------- <?xml version="1.0" encoding="UTF-8" ?> - <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema"> - <SOAP-ENV:Body> - <ns1:readHash xmlns:ns1="urn:hashtest" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> - <x xmlns:ns2="http://xml.apache.org/xml-soap" xsi:type="ns2:Map"> - <item> <key xsi:type="xsd:string">Test1</key> <value xsi:type="xsd:string">Value1</value> </item> - <item> <key xsi:type="xsd:string">Test3</key> <value xsi:type="xsd:string">Value3</value> </item> - <item> <key xsi:type="xsd:string">Test2</key> <value xsi:type="xsd:string">Value2</value> </item> </x> </ns1:readHash> </SOAP-ENV:Body> </SOAP-ENV:Envelope> - <!-- Generated by: String serverhost = "localhost"; String serverport= "85"; String soapservlet= "/soap/servlet/rpcrouter"; String urn= "urn:hashtest"; Vector params = new Vector (); Hashtable test = new Hashtable(); test.put("Test1","Value1"); test.put("Test2","Value2"); test.put("Test3","Value3"); params.addElement(new Parameter("x", Hashtable.class, test, null)); URL url = new URL ("http://" + serverhost + ":" + serverport+ soapservlet); Call call = new Call (); call.setTargetObjectURI (urn); call.setMethodName ( "readHash"); call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC); call.setParams (params); Response resp = call.invoke (url, "" ); --> ------------------------------------------------------------------------- The non-working SOAP::Lite XML ------------------------------------------------------------------------- <?xml version="1.0" encoding="UTF-8" ?> - <SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:namesp2="http://namespaces.soaplite.com/perl" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> - <SOAP-ENV:Body> - <namesp1:readHash xmlns:namesp1="urn:hashtest"> - <c-gensym4 xsi:type="namesp2:hashmap"> <msisdn xsi:type="xsd:int">14255551212</msisdn> </c-gensym4> </namesp1:readHash> </SOAP-ENV:Body> </SOAP-ENV:Envelope> - <!-- Produced as: -> readHash ( SOAP::Data->type(hashtable => {msisdn => '14255551212'} )) --> ------------------------------------------------------------------------- <?xml version="1.0" encoding="UTF-8" ?> - <SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:namesp2="http://namespaces.soaplite.com/perl" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> - <SOAP-ENV:Body> - <namesp1:readHash xmlns:namesp1="urn:hashtest"> - <SOAP-ENC:Array xsi:type="namesp2:hashmap" SOAP-ENC:arrayType="xsd:ur-type[2]"> <item xsi:type="xsd:string">msisdn</item> <item xsi:type="xsd:int">14255551212</item> </SOAP-ENC:Array> </namesp1:readHash> </SOAP-ENV:Body> </SOAP-ENV:Envelope> - <!-- Produced as: -> readHash ( SOAP::Data->type(hashmap => ['msisdn' => '14255551212'] )) --> ------------------------------------------------------------------------- <?xml version="1.0" encoding="UTF-8" ?> - <SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:namesp2="http://namespaces.soaplite.com/perl" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> - <SOAP-ENV:Body> - <namesp1:readHash xmlns:namesp1="urn:hashtest"> - <c-gensym4 xsi:type="namesp2:hashtable"> <msisdn xsi:type="xsd:int">14255551212</msisdn> </c-gensym4> </namesp1:readHash> </SOAP-ENV:Body> </SOAP-ENV:Envelope> - <!-- Produced as: -> readHash ( SOAP::Data->type(hashtable => {msisdn => '14255551212'} )) --> ------------------------------------------------------------------------- <?xml version="1.0" encoding="UTF-8" ?> - <SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:namesp2="http://namespaces.soaplite.com/perl" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> - <SOAP-ENV:Body> - <namesp1:readHash xmlns:namesp1="urn:hashtest"> - <SOAP-ENC:Array xsi:type="namesp2:hashtable" SOAP-ENC:arrayType="xsd:ur-type[2]"> <item xsi:type="xsd:string">msisdn</item> <item xsi:type="xsd:int">14255551212</item> </SOAP-ENC:Array> </namesp1:readHash> </SOAP-ENV:Body> </SOAP-ENV:Envelope> - <!-- Produced as: -> readHash ( SOAP::Data->type(hashtable => ['msisdn' => '14255551212'] )) --> ------------------------------------------------------------------------- Any assistance would be greatly appreciated. Thank you, Kayne McGladrey [EMAIL PROTECTED]
