I think I understand now. All SOAP services can return exactly one response. That one response can consist of many elements. I was thinking my reponse was a complex element when in fact I need to think of it as containing a complex element.
Thanks again, Doug -----Original Message----- From: Scott Nichol [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 04, 2003 6:11 PM To: [EMAIL PROTECTED] Subject: RE: Response Data Mapping Problems The <ns:GetAdapInfoResponse> element is *not* part of the XML you can map. You can only map elements within that one, i.e. that element delimits the response "parameters". It is *not* part of the "parameters" themselves. On 4 Mar 2003 at 7:25, Doug Haigh wrote: > I thought that the following line in my code did that for me > > smr.mapTypes(Constants.NS_URI_SOAP_ENC, > new QName("urn:remote-adap", "GetAdapInfoResponse"), > AdapterInfo.class, > beanSer, > beanSer); > > Why does this mapping not associate the 'GetAdapInfoResponse' XML structure > in the urn:remote-adap response into the AdapterInfo class? > > Doug > > -----Original Message----- > From: Scott Nichol [mailto:[EMAIL PROTECTED] > Sent: Tuesday, March 04, 2003 1:02 AM > To: [EMAIL PROTECTED] > Subject: Re: Response Data Mapping Problems > > > Just as the element > > <ns1:GetAdapterInfo xmlns:ns1="urn:remote-adap" > SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> > > is used to wrap the parameters for the method call, > > <ns:GetAdapInfoResponse> > > is used to wrap the return value and output parameters. In other > words, this element is not part of the return value, so you cannot > use this element as part of deserializing the return. If QueryError, > AdapterID, MemBase and IoBase are supposed to be members of a > structure, then they should be wrapped in an additional XML element, > such as > > <ns:GetAdapInfoResponse> > <AdapterInfo xsi:type="ns:AdapterInfo"> > <QueryError xsi:type="xsd:int">0</QueryError> > <AdapterID xsi:type="xsd:int">1</AdapterID> > <MemBase xsi:type="xsd:int">-100663296</MemBase> > <IoBase xsi:type="xsd:int">-68173824</IoBase> > </AdapterInfo> > </ns:GetAdapInfoResponse> > > > On 3 Mar 2003 at 20:43, Doug Haigh wrote: > > > I am trying to write a Java client that uses Apache SOAP to connect to a > > service running gSOAP. I have tried to model it after the addressbook > > example in the Apache SOAP toolkit. Unfortunately, when I get back the > > response, instead of mapping the data into an AdapterInfo object, the > > QueryError is mapped as the response value and the other fields in the > > struct are stuck in an vector. Can someone please tell me what is going > > wrong? > > > > Thanks > > > > > > --------------------------------------------- > > Code: > > > > > > public class AdapterInfo > > { > > private int QueryError; > > private int AdapterID; > > private int MemBase; > > private int IoBase; > > > > public AdapterInfo() > > { > > } > > > > public AdapterInfo( int QueryError, > > int AdapterID, > > int MemBase, > > int IoBase) > > { > > this.QueryError = QueryError ; > > this.AdapterID = AdapterID ; > > this.MemBase = MemBase ; > > this.IoBase = IoBase ; > > } > > > > > > public void setQueryError(int QueryError) > > { > > this.QueryError = QueryError; > > } > > > > public int getQueryError() > > { > > return QueryError; > > } > > > > > > public void setAdapterID(int AdapterID) > > { > > this.AdapterID = AdapterID; > > } > > > > public int getAdapterID() > > { > > return AdapterID; > > } > > > > > > public void setMemBase(int MemBase) > > { > > this.MemBase = MemBase; > > } > > > > public int getMemBase() > > { > > return MemBase; > > } > > > > > > public void setIoBase(int IoBase) > > { > > this.IoBase = IoBase; > > } > > > > public int getIoBase() > > { > > return IoBase; > > } > > > > > > public String toString() > > { > > return "Adapter ID = " + AdapterID + "\n" + > > "Query error = " + QueryError + "\n" + > > "Memory base = " + MemBase + "\n" + > > "IO base = " + IoBase + "\n"; > > } > > } > > > > > > public String GetAdapterInfo(int AdapterID) // Response??? > > { > > String output = ""; > > > > try > > { > > Call call = new Call(); > > SOAPMappingRegistry smr = new SOAPMappingRegistry(); > > BeanSerializer beanSer = new BeanSerializer(); > > Vector params = new Vector(); > > Response resp; > > > > smr.mapTypes(Constants.NS_URI_SOAP_ENC, > > new QName("urn:remote-adap", "GetAdapInfoResponse"), > > AdapterInfo.class, > > beanSer, > > beanSer); > > > > call.setSOAPMappingRegistry(smr); > > call.setTargetObjectURI("urn:remote-adap"); > > call.setMethodName("GetAdapterInfo"); > > call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC); > > > > params.addElement(new org.apache.soap.rpc.Parameter("Adapter", > > int.class, new Integer(AdapterID), null)); > > > > call.setParams(params); > > > > resp = call.invoke(ServerUrl, ""); > > > > System.out.println("invoke response=" + resp.generatedFault()); > > > > // Check the response. > > if (!resp.generatedFault()) > > { > > Vector retParams = resp.getParams(); > > Parameter ret = resp.getReturnValue(); > > Object info = ret.getValue(); > > int i; > > > > System.out.println("response body part=" + > > resp.getBodyPart(0).toString()); > > System.out.println("response part count=" + resp.getPartCount()); > > System.out.println("vector part count=" + retParams.size()); > > > > for (i=0; i < retParams.size(); i++) > > { > > Parameter param = (Parameter)retParams.elementAt(i); > > > > System.out.println("vector part "+i+" type=" + > > param.getValue().getClass()); > > } > > > > System.out.println("output type=" + info.getClass()); > > > > output = info.toString(); > > > > System.out.println("output=" + output); > > } > > else > > { > > Fault fault = resp.getFault(); > > > > System.err.println("Generated fault: " + fault); > > } > > } > > catch (SOAPException se) > > { > > System.err.println("Caught SOAPException (" + > > se.getFaultCode() + "): " + > > se.getMessage()); > > return output; > > } > > catch (MessagingException me) > > { > > System.err.println("Caught MessagingException:" + > > me.getMessage()); > > return output; > > } > > > > return output; > > } > > > > > > > > ------------------------------------------------------------ > > Request: > > > > <?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/2001/XMLSchema-instance" > > xmlns:xsd="http://www.w3.org/2001/XMLSchema"> > > <SOAP-ENV:Body> > > <ns1:GetAdapterInfo xmlns:ns1="urn:remote-adap" > > SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> > > <Adapter xsi:type="xsd:int">1</Adapter> > > </ns1:GetAdapterInfo> > > </SOAP-ENV:Body> > > </SOAP-ENV:Envelope> > > > > > > ------------------------------------------------------------ > > Response: > > > > <?xml version="1.0" encoding="UTF-8"?> > > <SOAP-ENV:Envelope > > xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" > > > > xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > > xmlns:xsd="http://www.w3.org/2001/XMLSchema" > > xmlns:ns="urn:remote-adap"> > > <SOAP-ENV:Body > > SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> > > <ns:GetAdapInfoResponse> > > <QueryError xsi:type="xsd:int">0</QueryError> > > <AdapterID xsi:type="xsd:int">1</AdapterID> > > <MemBase xsi:type="xsd:int">-100663296</MemBase> > > <IoBase xsi:type="xsd:int">-68173824</IoBase> > > </ns:GetAdapInfoResponse> > > </SOAP-ENV:Body> > > </SOAP-ENV:Envelope> > > > > > Scott Nichol > > Do not reply directly to this e-mail address, as it is filtered to > only receive e-mail from specific mailing lists. > > > > > Scott Nichol Do not reply directly to this e-mail address, as it is filtered to only receive e-mail from specific mailing lists.