Problem with .NET generated SOAP client

  • Thread starter Srikanth Subramanian
  • Start date
S

Srikanth Subramanian

All,

I'm having a problem with a VS.NET generated SOAP client that
connects to an existing Web service. The problem is that
the Web service is returning a single dimensional Array of strings,
but without an arrayType attribute. The .NET client fails to
deserialize the array content. My question is: Does .NET require
the "arrayType" attribute to be specified to be able to deserialize
an array ?


Here is the relevant portion of WSDL:

<types>
....
<xsd:complexType name="array">
<xsd:complexContent>
<xsd:restriction base="SOAP-ENC:Array">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0"
name="value"
type="xsd:string"/>
</xsd:sequence>
<xsd:attribute ref="SOAP-ENC:arrayType"
wsdl:arrayType="xsd:string
[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</types>

<message name="searchResponse">
<part name="return" type="tns:array"/>
</message>

<portType name=...>
<operation name="search">
<input message="tns:search"/>
<output message="tns:searchResponse"/>
</operation>
</portType>


The generated proxy class has a method of the form:
string[] search(...)
{
}


Here is the SOAP response message received from the Web service:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="salesforce" xmlns:types="salesforce/encodedTypes"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
<soap:Header/>
<soap:Body>
<return>
<valueArray xsi:type="tns:array">
<value xsi:type="xsd:string">abcd</value>
</valueArray>
</return>
</soap:Body>
</soap:Envelope>


If you notice, the encoded array (valueArray) in the SOAP message,
does not have the arrayType attribute (which according to spec, is
obligatory).

I get the following error:

Unhandled Exception: System.InvalidOperationException: There is an
error in XML
document (1, 423). ---> System.InvalidCastException: Cannot assign
object of typ
e System.Xml.XmlNode[] to an object of type System.String[].
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read
34_searchResponse()
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader
xmlReader)
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClie
ntMessage message, WebResponse response, Stream responseStream)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodN
ame, Object[] parameters)
at sf.localhost6.sfconnector.search(String type, String scope,
String searchV
alue, Int32 maxRows) in c:\dev\sf\web
references\localhost6\reference.cs:line 21
4
at sf.Class2.Main(String[] args) in c:\dev\sf\class2.cs:line 127



Why is .NET not able to deserialize this array into a string[] ?
I have tried playing with the WSDL type specification for the custom
"array" type, but with no success - everytime the .NET client throws
an exception about being unable to assign to a string[].

Any help would be appreciated. Thanks !

-Srikanth
 
L

Lewis Wang [MSFT]

Hi Srikanth,

Sorry for the late reply.

I have done a lot of research on this issue. It seems a SPEC conflict, but
I can not reproduce it. Was the web service developed using VS.NET? Would
you please give me the web service URL to reproduce this problem? Thanks.

I am looking forward to your reply.

Best regards,
Lewis
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| From: (e-mail address removed) (Srikanth Subramanian)
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
| Subject: Problem with .NET generated SOAP client
| Date: 4 Sep 2003 09:09:51 -0700
| Organization: http://groups.google.com/
| Lines: 105
| Message-ID: <[email protected]>
| NNTP-Posting-Host: 12.96.166.132
| Content-Type: text/plain; charset=ISO-8859-1
| Content-Transfer-Encoding: 8bit
| X-Trace: posting.google.com 1062691791 24239 127.0.0.1 (4 Sep 2003
16:09:51 GMT)
| X-Complaints-To: (e-mail address removed)
| NNTP-Posting-Date: 4 Sep 2003 16:09:51 GMT
| Path:
cpmsftngxa06.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP08
..phx.gbl!newsfeed00.sul.t-online.de!t-online.de!news-spur1.maxwell.syr.edu!n
ews.maxwell.syr.edu!newsfeed.frii.net!newsfeed.frii.net!140.99.99.194.MISMAT
CH!newsfeed1.easynews.com!easynews.com!easynews!sn-xit-02!sn-xit-06!sn-xit-0
9!supernews.com!postnews1.google.com!not-for-mail
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.aspnet.webservices:19186
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
|
| All,
|
| I'm having a problem with a VS.NET generated SOAP client that
| connects to an existing Web service. The problem is that
| the Web service is returning a single dimensional Array of strings,
| but without an arrayType attribute. The .NET client fails to
| deserialize the array content. My question is: Does .NET require
| the "arrayType" attribute to be specified to be able to deserialize
| an array ?
|
|
| Here is the relevant portion of WSDL:
|
| <types>
| ...
| <xsd:complexType name="array">
| <xsd:complexContent>
| <xsd:restriction base="SOAP-ENC:Array">
| <xsd:sequence>
| <xsd:element maxOccurs="unbounded" minOccurs="0"
| name="value"
| type="xsd:string"/>
| </xsd:sequence>
| <xsd:attribute ref="SOAP-ENC:arrayType"
| wsdl:arrayType="xsd:string
| []"/>
| </xsd:restriction>
| </xsd:complexContent>
| </xsd:complexType>
| </types>
|
| <message name="searchResponse">
| <part name="return" type="tns:array"/>
| </message>
|
| <portType name=...>
| <operation name="search">
| <input message="tns:search"/>
| <output message="tns:searchResponse"/>
| </operation>
| </portType>
|
|
| The generated proxy class has a method of the form:
| string[] search(...)
| {
| }
|
|
| Here is the SOAP response message received from the Web service:
|
| <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
| xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
| xmlns:tns="salesforce" xmlns:types="salesforce/encodedTypes"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
| <soap:Header/>
| <soap:Body>
| <return>
| <valueArray xsi:type="tns:array">
| <value xsi:type="xsd:string">abcd</value>
| </valueArray>
| </return>
| </soap:Body>
| </soap:Envelope>
|
|
| If you notice, the encoded array (valueArray) in the SOAP message,
| does not have the arrayType attribute (which according to spec, is
| obligatory).
|
| I get the following error:
|
| Unhandled Exception: System.InvalidOperationException: There is an
| error in XML
| document (1, 423). ---> System.InvalidCastException: Cannot assign
| object of typ
| e System.Xml.XmlNode[] to an object of type System.String[].
| at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read
| 34_searchResponse()
| --- End of inner exception stack trace ---
| at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader
| xmlReader)
| at
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClie
| ntMessage message, WebResponse response, Stream responseStream)
| at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
| methodN
| ame, Object[] parameters)
| at sf.localhost6.sfconnector.search(String type, String scope,
| String searchV
| alue, Int32 maxRows) in c:\dev\sf\web
| references\localhost6\reference.cs:line 21
| 4
| at sf.Class2.Main(String[] args) in c:\dev\sf\class2.cs:line 127
|
|
|
| Why is .NET not able to deserialize this array into a string[] ?
| I have tried playing with the WSDL type specification for the custom
| "array" type, but with no success - everytime the .NET client throws
| an exception about being unable to assign to a string[].
|
| Any help would be appreciated. Thanks !
|
| -Srikanth
|
 
L

Lewis Wang [MSFT]

Hi Srikanth,

Thank you for your update.

Everything is OK if I create the web service and client using VS.NET. I
think the reason causing this issue is that the web service client written
by VS.NET did not deserialize the soap message correctly. Since I can not
get the web service URL, I will do more research on it and try to reproduce
this issue.

Best regards,
Lewis
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| From: (e-mail address removed) (Srikanth Subramanian)
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
| Subject: Re: Problem with .NET generated SOAP client
| Date: 8 Sep 2003 11:30:58 -0700
| Organization: http://groups.google.com/
| Lines: 19
| Message-ID: <[email protected]>
| References: <[email protected]>
<OI09#[email protected]>
| NNTP-Posting-Host: 12.96.166.132
| Content-Type: text/plain; charset=ISO-8859-1
| Content-Transfer-Encoding: 8bit
| X-Trace: posting.google.com 1063045860 11811 127.0.0.1 (8 Sep 2003
18:31:00 GMT)
| X-Complaints-To: (e-mail address removed)
| NNTP-Posting-Date: 8 Sep 2003 18:31:00 GMT
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-onlin
e.de!npeer.de.kpn-eurorings.net!newsfeed.news2me.com!elnk-nf2-pas!elnk-pas-n
f1!newsfeed.earthlink.net!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-09!supernews.
com!postnews1.google.com!not-for-mail
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.aspnet.webservices:19258
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
|
| Hi Lewis,
|
| Thanks for replying. First, the webservice is a legacy service that
| was not written using VS.NET (I'm not 100% sure, but I'm pretty certain).
| Next, the webservice APIs require a paid subscription (with login
| authentication) so even if I give you the service URL, you cannot call
any of
| the services without the login information.
|
| You mentioned a conflict in the spec - did you mean a conflict in the
| requirement of the "arrayType" attribute in SOAP-encoding an array ?
| If so, that was the information I was looking for. So when you say that
| you are not able to reproduce the problem, is it because all web services
| implemented using VS.NET and most others, (correctly) generate the
arrayType
| attribute when serializing an array ? And you dont have access to any
| webservices that behave the way I described ?
|
| Thanks for the info.
|
| -Srikanth
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top