array deserialization in Axis webservice repsonses

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: parrot toes (parrottoes_at__WILL_NOT_RESPOND_hotmail.com.(donotspam))
Date: 11/12/04


Date: Thu, 11 Nov 2004 18:16:01 -0800

I tried to post this question before, but there was an error when posting.
I case it did get posted and in order to avoid duplication, I'll just repost
a summary.

I have written a dotnet client that accesses a Axis provided web service.
The client uses the code generated, using wsdl.exe, from the wsdl file
provided by the web service provider.

The web response has the following schema (roughly):

public class response {

public string elem1;
public thing[] elem2;

}

public class thing {
public string thingy1;
public string thingy2;
}

i.e. the response has an array of custom objects within a custom object.

I do not have access to the server, I can't make changes to it. I may be
able to convince service provider to make changes, though.

When processing the response, I the following is thrown:
System.InvalidOperationException: There is an error in XML document (12,
19). ---> System.InvalidCastException: Cannot assign object of type
System.Object[] to an object of type customertransactions.thing[].
   at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read3_ResponseModel()
   at
System.Xml.Serialization.XmlSerializationReader.ReadReferencingElement(String
name, String ns, Boolean elementCanBeType, String& fixupReference)
   at System.Xml.Serialization.XmlSerializationReader.ReadReferencedElements()
   at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read6_walletPaymentResponse()

I've read at
http://www.mail-archive.com/axis-dev@xml.apache.org/msg00195.html that there
are deserialization issues with certain elements. e.g. if the element is an
array of other stuff, but the element is defined as anyType[n], then the
contents may get put into an object array (object[]) instead of into the
appropriate array (thing[]). I would guess from the exception that this is
happening (an that the exception is thrown when the application tries to
assign the object[] to the Response.elem2 property).

I have managed to intercept and modify the SOAP response prior to
deserialization.
The SOAP response does define the offending array element as a anyType[2]. I
even managed to modify the response prior to deserialization and changed it
to thing[2].
When I did that, the exception went away and the response contents were
properly stuffed into the response oject.

My question is this. My solution is ugly and specific to a particular SOAP
message.
I thought that a purpose of webservices and wsdl was to remove the developer
from the loop - the web service details are handled by a wsdl processor and
as such the developer doesn't mess with the details of request formatting and
response parsing.

Is there a way that I am supposed to use wsdl and the resulting proxy class
that will allow me to consume an Axis service with a dotnet client? Is there
a problem with either the dotnet deserialization or the Axis serialization of
arrays.
Is there a known Axis issue that requires the service provider to adjust
some stuff in order to service dotnet clients?

Thanks for your time.



Relevant Pages

  • Re: SOAP serialization problem
    ... I've snooped the SOAP response, ... this deserialization, but I've not found any that work. ... You're the client and you are the customer of a Web service that's for your use only. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: SOAP serialization problem
    ... I've snooped the SOAP response, ... public string XmlTest{ ... this deserialization, but I've not found any that work. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: SocketChannel.write(ByteBuffer src) problem
    ... If your problem persists, wouldn't it be worth your while to consider ... I'm also pulling the exact same data into a byte array and then ... I would get a response back. ...
    (comp.lang.java.programmer)
  • Re: Use VB array as as argument for worksheet function
    ... to me that he knew what an array is. ... why would the replier not see the response. ... (there's no email, no snail mail, but somewhere should be gmail in my addy) ... should be teaching the Newbie, ...
    (microsoft.public.excel.programming)
  • WCF error deserializing my Response Object
    ... Error deserializing my Response Object ... another type 'System.Collections.ArrayList' with the same data contract name ... [DataMember] ... public String UserID ...
    (microsoft.public.dotnet.languages.csharp)