Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / November 2004

Tip: Looking for answers? Try searching our database.

array deserialization in Axis webservice repsonses

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
parrot toes - 12 Nov 2004 02:16 GMT
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.
parrot toes - 12 Nov 2004 17:00 GMT
Please diregard my original post in this thread. I noticed that my first
attempt at posting this question did in fact make it onto the discussion
board. Please refer to it, "deserialization arrays in Axis SOAP messages"
posted 11/11/2004, intead.

Sorry.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.