Re: SOAP serialization problem

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



On Fri, 14 Aug 2009 12:11:32 -0400, Mr. Arnold wrote:

"Jeff Dege" <jdege@xxxxxxxxxxxxxx> wrote in message
news:EYOdnYniw9bA5BjXnZ2dnUVZ_r9i4p2d@xxxxxxxxxxxxxx
On Fri, 14 Aug 2009 09:58:25 -0400, Mr. Arnold wrote:

"Jeff Dege" <jdege@xxxxxxxxxxxxxx> wrote in message
news:H_SdnXeH482DwRjXnZ2dnUVZ_g1i4p2d@xxxxxxxxxxxxxx
On Thu, 13 Aug 2009 19:02:31 -0400, Mr. Arnold wrote:

"Jeff Dege" <jdege@xxxxxxxxxxxxxx> wrote in message
news:9tKdnZWhBf3VHRnXnZ2dnUVZ_tednZ2d@xxxxxxxxxxxxxx
I'm trying to write a client against a third party's web service
using ASP.NET 3.5. I'm getting an error when the generated proxy
deserializes the response:

"Cannot assign object of type System.Xml.XmlNode[] to an object of
type System.String."

This exception is thrown by the generated proxy class on
this.Invoke().

I've snooped the SOAP response, and it looks fine. The wsdl
validates, and wsdl.exe compiles it without error.

Browsing around on the net has given me the vague impression that I
might need to set some sort of custom serialization attribute, but
I've not been able to figure out what that might be.

Any ideas?

Contact the Web Service provider?

I am in contact with them. They're working with the PHP SOAP
Extension, and their test client works just fine.

Their test client based on what, Java?

If they need to make a change, in
order for ASP.NET to work with their responses, what change do they
need to make?


"Cannot assign object of type System.Xml.XmlNode[] to an object of
type System.String."

[System.Web.Services.Protocols.SoapRpcMethodAttribute(
"http://www.XXX.com/webservices/service.php/XmlTest";,
RequestNamespace="http://www.XXX.com/webservices";,
ResponseNamespace="http://www.XXX.com/webservices";)]
[return: System.Xml.Serialization.SoapElementAttribute("result")]
public string XmlTest(string xml_msg) {
object[] results = this.Invoke("XmlTest", new object[] {
xml_msg});
return ((string)(results[0]));
}

-------

I don't see how the statements above are going to work. It can't take
an array - [] object type and assign it to a primitive object type of
String. That's the issue you need to address and not some
serialization problem. There seems to be a misinterpretation of the
XML schema that needs to be resolved between you and the 3rd party
provider.

The wsdl says:

<portType name="AEWebServicePortType"> <operation name="XmlTest">
<input message="tns:XmlTestRequest"/> <output
message="tns:XmlTestResponse"/> </operation>
</portType>

Where:

<message name="XmlTestResponse">
<part name="result" type="tns:XmlOut"/> </message>

And:

<simpleType name="XmlOut">
<restriction base = "xsd:string"/>
</simpleType>

The SOAP response contains:

<ns1:XmlTestResponse>
<result xsi:type="ns2:XmlOut">
Test Message
</result>
</ns1:XmlTestResponse>

This looks consistent, to me.

It's wsdl.exe that has decided that "result" should be converted to a
string, instead of to some other type, and it's wsdl.exe that then
can't convert it to a string. I've tried using other return types for
this deserialization, but I've not found any that work. Everything
I've tried has either been undefined or has generated the same error.

[return: System.Xml.Serialization.SoapElementAttribute("result")]
public string XmlTest(string xml_msg) {
object[] results = this.Invoke("XmlTest", new object[] {
xml_msg});
return ((string)(results[0]));
}

"Value 'any' cannot be used for the SoapElementAttribute.DataType
property. The datatype 'http://www.w3.org/2001/XMLSchema:any' is
missing."


Either they have to change what they're sending, or I have to change
how .NET's deserialization handles it. But what change do we need to
make?


You say they have a test client that worked? Test client based on what
platform solution, .NET?

No. I think they're testing it with a PHP web page.

They have any other clients that are .NET that worked, other than you,
that it doesn't work?

Nope.

I would say that they are going to have to provide a XML solution that's
going to work on the .NET platform if they have not already done so.

This is an interface that's being written specifically for the project,
there are no other customers, just me.

I've never tried to connect to an rpc/encoded SOAP service before, and
I've never had a problem connecting to a document/literal SOAP service.

And it's not like we're passing complex arguments - string in and string
out.

When we first raised the issue, they came back with "the PHP SOAP
extension only support rpc/encoded". A fair amount of web browsing has
convinced me that's simply not true, for recent versions of the PHP SOAP
extension, at least.

At this point, I'm faced with either finding some other tool to interface
with the webservice that better supports rpc/encoded (which will be
difficult, because all of the library code for handling the data is
written in .NET, or convincing them to switch to document/literal, with
no guarantee that there won't still be problems.

Is there a way I can write a SOAP client that gets the SOAP response
before the deserialization? If I could, I could parse the response
myself. But SoapHttpClientProtocol.Invoke() returns the result of the
deserialization, I can't see how to access the raw response..

--
We have an inveterate dislike of the profusion of safety devices with
which all automatic pistols are regularly equipped. We believe them
to be the cause of more accidents than anything else. There are too
many instances on record of men being shot by accident either because
the safety-catch was in the firing position when it ought not to have
been or because it was in the safe position when that was the last thing
to be desired. It is better, we think, to make the pistol permanently
"unsafe" and then to devise such methods of handling it that there will
be no accidents.
- Captain William Ewart Fairbairn and Captain Eric Anthony Sykes
.



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, ... and their test client works just fine. ... string XmlTest{ ... deserialization, but I've not found any that work. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: SOAP serialization problem
    ... This exception is thrown by the generated proxy class on ... I've snooped the SOAP response, ... string XmlTest{ ... deserialization, but I've not found any that work. ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: Soap href tag not being deserialized by .Net Framework
    ... I'm facing an odd problem when consuming some web services in .Net. ... the response SOAP envelope isn't being deserialized ... and that problem is on .net deserialization ...
    (microsoft.public.dotnet.framework.webservices)
  • deserialization arrays in Axis SOAP messages
    ... I have been trying to make requests of a web service provided by Axis using ... As a result of seraching news groups I guessed that the SOAP response ... defines an array element in a way that causes the dotnet deserialization ... I used SOAP extensions to manipulate the offending item in the SOAP ...
    (microsoft.public.dotnet.framework.webservices)