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:33:36 UTC

RE: setting response deserializers dynamically not based on eleme nt names (Java client to MS .NET server)

Steve, thanks for all your help.

Your solution does look good.  The problem in my case is that I am only
writing the client.  Someone else is writing the server side stuff.  We used
the RPC method when we first started (before I hot to map the deserializers)
and I believe that wasn't an option for some reason.  I will ask the other
team again but I believe they will say no to your solution.  Is there any
drawbacks to adding the [SoapRpcService()] and [SoapRpcMethod()] to our
server WebServices?  Thanks.

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


-----Original Message-----
From: Steeve Gilbert [mailto:Steeve_Gilbert@canammanac.com]
Sent: Wednesday, August 01, 2001 10:13 AM
To: soap-user@xml.apache.org
Subject: Re: setting response deserializers dynamically not based on
element n ames (Java client to MS .NET server)



Hi Pete!

I think you'll be happy with this one.  Add the [SoapRpcService()] before
your class and [SoapRpcMethod()] before your method and now they should add
the datatype in the soap response.  That's what I did and it's working
great.  The code looks like this...

namespace DotNetService
{
     [SoapRpcService()]
     [WebService(Namespace="urn:DUJS/", Description="Services SOAP offert
par le .NET.")]
     public class DUNETService : System.Web.Services.WebService
     {
          [WebMethod(Description="Calcul le plus petit denominateur pour le
nombre passé en paramètre.")]
          [SoapRpcMethod()]
          public int PPD(int number)
          {
               int return_ppd = 2;

               return return_ppd;
          }
}

Good luck!  Tell me if it's not working.

Steeve...





Pete Roth <pr...@telemetrytech.net> on 01/08/2001 10:10:42 AM

Please respond to soap-user@xml.apache.org

To:   "Soap-dev List (E-mail)" <so...@xml.apache.org>, "Soap-user list
      (E-mail)" <so...@xml.apache.org>
cc:    (bcc: Steeve Gilbert/G_STGEORGES/CANAM_MANAC)

Subject:  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