Ask a Question related to ASP.NET Web Services, Design and Development.
-
Srikanth Subramanian #1
Problem with .NET generated SOAP client
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.XmlS erializationReader1.Read
34_searchResponse()
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader
xmlReader)
at System.Web.Services.Protocols.SoapHttpClientProtoc ol.ReadResponse(SoapClie
ntMessage message, WebResponse response, Stream responseStream)
at System.Web.Services.Protocols.SoapHttpClientProtoc ol.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
Srikanth Subramanian Guest
-
is there a way to control tag names in generated soap message
When I define a webservice: SOURCE: public string Crunch(string bite) { return "{"+ruff.ToLower()+"}"; } -
Writing a HTML/ASP SOAP client for a SOAP::Lite destination
How would I go about writing a SOAP client in either HTML or classic asp? The SOAP "listener" was written in Perl with SOAP::Lite in Unix and I am... -
SOAP over SSL? NotSupportedException in generated client proxy code
Hi all, I used the wizards in VC.NET to generate code to generate a client proxy for a web service in the usual manner. The .WSDL file is... -
How do I override the soap:address field in the auto-generated WSDL document?
My web service will be served on a farm of servers. However, the WSDL document that get's created uses information about the local machine. More... -
SOAP Client creation in ASP.NET using MS SOAP Toolkit
how would I create a SOAP client in ASP.Net? The following code just works fine in VB: Dim lobjSOAP As New MSSOAPLib30.SoapClient30... -
Lewis Wang [MSFT] #2
RE: Problem with .NET generated SOAP client
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: [email]srik_subramanian@hotmail.com[/email] (Srikanth Subramanian)
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webservic es
| Subject: Problem with .NET generated SOAP client
| Date: 4 Sep 2003 09:09:51 -0700
| Organization: [url]http://groups.google.com/[/url]
| Lines: 105
| Message-ID: <8f763cc4.0309040809.2466659a@posting.google.com >
| 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: [email]groups-abuse@google.com[/email]
| NNTP-Posting-Date: 4 Sep 2003 16:09:51 GMT
| Path:
cpmsftngxa06.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTN GXA05.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.fri i.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.webservic es:19186
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservic es
|
| 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.XmlS erializationReader1.Read
| 34_searchResponse()
| --- End of inner exception stack trace ---
| at System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader
| xmlReader)
| at
System.Web.Services.Protocols.SoapHttpClientProtoc ol.ReadResponse(SoapClie
| ntMessage message, WebResponse response, Stream responseStream)
| at System.Web.Services.Protocols.SoapHttpClientProtoc ol.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
|
Lewis Wang [MSFT] Guest
-
Lewis Wang [MSFT] #3
Re: Problem with .NET generated SOAP client
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: [email]srik_subramanian@hotmail.com[/email] (Srikanth Subramanian)
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webservic es
| Subject: Re: Problem with .NET generated SOAP client
| Date: 8 Sep 2003 11:30:58 -0700
| Organization: [url]http://groups.google.com/[/url]
| Lines: 19
| Message-ID: <8f763cc4.0309081030.765ce924@posting.google.com >
| References: <8f763cc4.0309040809.2466659a@posting.google.com >
<OI09#OgdDHA.2000@cpmsftngxa06.phx.gbl>
| 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: [email]groups-abuse@google.com[/email]
| NNTP-Posting-Date: 8 Sep 2003 18:31:00 GMT
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed 00.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.webservic es:19258
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservic es
|
| 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
|
Lewis Wang [MSFT] Guest



Reply With Quote

