You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@ws.apache.org by Pete Roth <pr...@telemetrytech.net> on 2001/08/01 16:10:42 UTC

setting response deserializers dynamically not based on element n ames (Java client to MS .NET server)

I have a response envelope that will look like the XML sample below.  What I
need to do is read in all that data.  I now, with the help of users of this
group, am able to build the response as an XML document and can parse it
that way.  The problem is that since I am using a .NET server that doesn't
return the xsi:type attribute on each data element, I need to manually set
up deserializers for each element returned by the server.  When I use this
method in my SOAP wrapper class:

public void setDeserializer(org.apache.soap.util.xml.Deserializer[] des,
String[] rsponseItemNamespaces, String[]responseItemNames) {
    for (int i=0; i<des.length;i++) {
      if(des[i] == null) return;
      _smr.mapTypes(Constants.NS_URI_SOAP_ENC,
                    new QName(responseItemNamespaces[i],
responseItemNames[i]),  
                              null, null, des[i]); 
    }
    _call.setSOAPMappingRegistry(_smr); 				
}

To map the deserializers to the response elements.  Now this works for one
element returned, but if I try to use it for the method which returns the
below XML (passing all the deserializers, element namespaces, and element
names of course) It tells me that "device_getCurrentMessageResult" there is
no deserialzier to deserialize a
"namespacehere:device_getCurrentMessageResult".  What's up with that?  

Also, Since I am getting the response as XML and parsing it myself, I would
just like to specify to use the StringDeserializer for all the data
regardless of how many elements are returned in the SOAP envelope.  That way
if the names or number of elements change, in the method response, I won't
have to change my client code, if I code it carefully.

Does anyone know how I can just use StringDeserializer for the entire
response so I don't have to know the names of all the elements returned in
the SOAP envelope?  Remember, I am using a .NET server that doesn't add the
xsi:type attribute.  

Any help would be greatly appreciated.  Thanks.


*******************
Sample XML response
****************************************************************************
*

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <device_getCurrentMessageResponse
xmlns="http://telemetrytech.net/VnocngWebService">
      <device_getCurrentMessageResult>
        <vnVNOC ThisTransactionTime="string">
          <VnocAddress>string</VnocAddress>
          <UserAddress>string</UserAddress>
          <Disclaimer>string</Disclaimer>
          <Copyright>string</Copyright>
        </vnVNOC>
        <vnDevice AccountID="string" DeviceIDInternal="int"
AdminLevelAccess="boolean" AccountIDInternal="int">
          <GroupName>string</GroupName>
          <DeviceName>string</DeviceName>
        </vnDevice>
        <vnDeviceInboundMsg MessageID="string">
          <MessageEncoding>string</MessageEncoding>
          <MessageTime>string</MessageTime>
          <MessageTimeUTC>string</MessageTimeUTC>
          <MessageData>string</MessageData>
          <MessageDataPreParsed>string</MessageDataPreParsed>
          <MessageDataLenIn>string</MessageDataLenIn>
        </vnDeviceInboundMsg>
      </device_getCurrentMessageResult>
    </device_getCurrentMessageResponse>
  </soap:Body>
</soap:Envelope>

****************************************************************************
*

Peter Roth
Telemetry Technologies Inc.
p: 404.231.0021 ext. 1290
e: proth@TelemetryTech.net