473,326 Members | 2,147 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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

Hi!

I'm working with a C# client that calls a php web service. I've
created a wrapper to call the service using .NET wsdl tool (adding a
web reference).

The call to the server works fine, it is serialized correctly, and the
server returns a response (I've captured the response and it's
correct!) but when the .NET deserialize this response, it throws the
exception "System.InvalidOperationException: There is an error in XML
document (1, 541). ---> System.InvalidCastException: Cannot assign
object of type System.Xml.XmlNode[] to an object of type
System.String." (The full exception text is detailed at the end of the
message).

The particular thing of the web service operation is that uses input
and output parameters, perhaps that's the problem?

Can anybody helps me?

Thanks a lot in advance,

Marc.

************ WSDL starts here ***************
<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:s0="urn:emisiowsdl"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
targetNamespace="urn:emisiowsdl"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
<s:schema targetNamespace="urn:emisiowsdl">
<s:import namespace="http://schemas.xmlsoap.org/soap/encoding/"
/>
<s:import namespace="http://schemas.xmlsoap.org/wsdl/" />
<s:complexType name="TIntegerList">
<s:complexContent mixed="false">
<s:restriction base="soapenc:Array">
<s:attribute d7p1:arrayType="s0:TInteger[]"
ref="soapenc:arrayType" xmlns:d7p1="http://schemas.xmlsoap.org/wsdl/"
/>
</s:restriction>
</s:complexContent>
</s:complexType>
<s:complexType name="TKeyValue">
<s:all>
<s:element name="key" type="s:string" />
<s:element name="value" type="s:string" />
</s:all>
</s:complexType>
<s:complexType name="TAssociativeArray">
<s:complexContent mixed="false">
<s:restriction base="soapenc:Array">
<s:attribute d7p1:arrayType="s0:TKeyValue[]"
ref="soapenc:arrayType" xmlns:d7p1="http://schemas.xmlsoap.org/wsdl/"
/>
</s:restriction>
</s:complexContent>
</s:complexType>
<s:complexType name="TAssociativeArrayList">
<s:complexContent mixed="false">
<s:restriction base="soapenc:Array">
<s:attribute d7p1:arrayType="s0:TAssociativeArray[]"
ref="soapenc:arrayType" xmlns:d7p1="http://schemas.xmlsoap.org/wsdl/"
/>
</s:restriction>
</s:complexContent>
</s:complexType>
<s:simpleType name="TString">
<s:restriction base="s:string" />
</s:simpleType>
<s:simpleType name="TInteger">
<s:restriction base="s:int" />
</s:simpleType>
<s:simpleType name="TFloat">
<s:restriction base="s:float" />
</s:simpleType>
</s:schema>
</types>
<message name="ObtenirPrimaTotal_ProjecteRequest">
<part name="Login" type="s0:TString" />
<part name="Password" type="s0:TString" />
<part name="CodiMediador" type="s0:TString" />
<part name="DataEfecte" type="s0:TString" />
<part name="DataVenciment" type="s0:TString" />
<part name="FormaPagament" type="s0:TString" />
<part name="LlistaModalitats" type="s0:TAssociativeArrayList" />
<part name="LlistaRiscs" type="s0:TAssociativeArrayList" />
<part name="LlistaClausules" type="s0:TIntegerList" />
</message>
<message name="ObtenirPrimaTotal_ProjecteResponse">
<part name="CodiError" type="s0:TString" />
<part name="TexteError" type="s0:TString" />
<part name="PrimaNeta" type="s0:TFloat" />
<part name="PrimaNetaImpostos" type="s0:TFloat" />
<part name="PrimaNetaTotalRebut" type="s0:TFloat" />
<part name="PrimaAnual" type="s0:TFloat" />
<part name="PrimaAnualImpostos" type="s0:TFloat" />
<part name="PrimaAnualTotalRebut" type="s0:TFloat" />
</message>
<portType name="emisiowsdlPortType">
<operation name="ObtenirPrimaTotal_Projecte">
<documentation>Retorna la prima d'una plissa</documentation>
<input message="s0:ObtenirPrimaTotal_ProjecteRequest" />
<output message="s0:ObtenirPrimaTotal_ProjecteResponse" />
</operation>
</portType>
<binding name="emisiowsdlBinding" type="s0:emisiowsdlPortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="rpc" />
<operation name="ObtenirPrimaTotal_Projecte">
<soap:operation
soapAction="urn:emisiowsdl#ObtenirPrimaTotal_Proje cte" style="rpc" />
<input>
<soap:body use="encoded" namespace="urn:emisiowsdl"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output>
<soap:body use="encoded" namespace="urn:emisiowsdl"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
</operation>
</binding>
<service name="emisiowsdl">
<port name="emisiowsdlPort" binding="s0:emisiowsdlBinding">
<soap:address location="https://www.dummy.net:11110/WebService.php?webservice=emisio/server.php"
/>
</port>
</service>
</definitions>
************ WSDL ends here ***************
************ Response starts here ***********
<?xml version="1.0" encoding="ISO-8859-1"?>
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:si="http://soapinterop.org/xsd" xmlns:tns="urn:emisiowsdl">
<SOAP-ENV:Body>
<ns1:ObtenirPrimaTotal_ProjecteResponse
xmlns:ns1="urn:emisiowsdl">
<CodiError xsi:type="tns:TString">
</CodiError>
<TexteError xsi:type="tns:TString">
</TexteError>
<PrimaNeta xsi:type="tns:TFloat">30.89</PrimaNeta>
<PrimaNetaImpostos
xsi:type="tns:TFloat">1.94</PrimaNetaImpostos>
<PrimaNetaTotalRebut
xsi:type="tns:TFloat">32.83</PrimaNetaTotalRebut>
<PrimaAnual xsi:type="tns:TFloat">30.81</PrimaAnual>
<PrimaAnualImpostos
xsi:type="tns:TFloat">1.94</PrimaAnualImpostos>
<PrimaAnualTotalRebut
xsi:type="tns:TFloat">32.75</PrimaAnualTotalRebut>
</ns1:ObtenirPrimaTotal_ProjecteResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
************ Response ends here ***********

************** Exception Text starts here **************
System.InvalidOperationException: There is an error in XML document
(1, 541). ---> System.InvalidCastException: Cannot assign object of
type System.Xml.XmlNode[] to an object of type System.String.
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read5_ObtenirPrimaTotal_Projec teResponse()
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader
xmlReader, String encodingStyle)
at System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader
xmlReader)
at System.Web.Services.Protocols.SoapHttpClientProtoc ol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream, Boolean
asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtoc ol.Invoke(String
methodName, Object[] parameters)
at TestWrapperARAG.net.aragonline.www.emisiowsdl.ObtenirPrimaTotal_Projecte(String
Login, String Password, String CodiMediador, String DataEfecte, String
DataVenciment, String FormaPagament, TKeyValue[][] LlistaModalitats,
TKeyValue[][] LlistaRiscs, Int32[] LlistaClausules, String&
TexteError, Single& PrimaNeta, Single& PrimaNetaImpostos, Single&
PrimaNetaTotalRebut, Single& PrimaAnual, Single& PrimaAnualImpostos,
Single& PrimaAnualTotalRebut) in
d:\mtomas\projects\tarificador2.0\arag\testwrapper arag\referencias
web\net.aragonline.www\reference.cs:line 55
at TestWrapperARAG.Form1.button1_Click(Object sender, EventArgs e)
in d:\mtomas\projects\tarificador2.0\arag\testwrapper arag\form1.cs:line
134
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage (Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(M essage& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)
************** Exception Text ends here **************
Nov 23 '05 #1
1 18089
Hi all!

I've found the problem! (but now I want the best solution! :( )

The types for the response parameters of the wsdl, are derivated from
the xsd types, TFloat, TString, ... If I manipulate the response
before deserialize and I replace "tns:TFloat" with "xsd:float" (and
"tns:TString" with "xsd:string", ....) the response is serialized
correctly by .NET, WHY?

So, I can use a SOAPExtension to replace the types before deserialize,
but it's a little dirty, isn't it!? Is there any better solution?

Thanks in advance,

Marc.

do**********@hotmail.com (Marc) wrote in message news:<8c**************************@posting.google. com>...
Hi!

I'm working with a C# client that calls a php web service. I've
created a wrapper to call the service using .NET wsdl tool (adding a
web reference).

The call to the server works fine, it is serialized correctly, and the
server returns a response (I've captured the response and it's
correct!) but when the .NET deserialize this response, it throws the
exception "System.InvalidOperationException: There is an error in XML
document (1, 541). ---> System.InvalidCastException: Cannot assign
object of type System.Xml.XmlNode[] to an object of type
System.String." (The full exception text is detailed at the end of the
message).

The particular thing of the web service operation is that uses input
and output parameters, perhaps that's the problem?

Can anybody helps me?

Thanks a lot in advance,

Marc.

************ WSDL starts here ***************
<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:s0="urn:emisiowsdl"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
targetNamespace="urn:emisiowsdl"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
<s:schema targetNamespace="urn:emisiowsdl">
<s:import namespace="http://schemas.xmlsoap.org/soap/encoding/"
/>
<s:import namespace="http://schemas.xmlsoap.org/wsdl/" />
<s:complexType name="TIntegerList">
<s:complexContent mixed="false">
<s:restriction base="soapenc:Array">
<s:attribute d7p1:arrayType="s0:TInteger[]"
ref="soapenc:arrayType" xmlns:d7p1="http://schemas.xmlsoap.org/wsdl/"
/>
</s:restriction>
</s:complexContent>
</s:complexType>
<s:complexType name="TKeyValue">
<s:all>
<s:element name="key" type="s:string" />
<s:element name="value" type="s:string" />
</s:all>
</s:complexType>
<s:complexType name="TAssociativeArray">
<s:complexContent mixed="false">
<s:restriction base="soapenc:Array">
<s:attribute d7p1:arrayType="s0:TKeyValue[]"
ref="soapenc:arrayType" xmlns:d7p1="http://schemas.xmlsoap.org/wsdl/"
/>
</s:restriction>
</s:complexContent>
</s:complexType>
<s:complexType name="TAssociativeArrayList">
<s:complexContent mixed="false">
<s:restriction base="soapenc:Array">
<s:attribute d7p1:arrayType="s0:TAssociativeArray[]"
ref="soapenc:arrayType" xmlns:d7p1="http://schemas.xmlsoap.org/wsdl/"
/>
</s:restriction>
</s:complexContent>
</s:complexType>
<s:simpleType name="TString">
<s:restriction base="s:string" />
</s:simpleType>
<s:simpleType name="TInteger">
<s:restriction base="s:int" />
</s:simpleType>
<s:simpleType name="TFloat">
<s:restriction base="s:float" />
</s:simpleType>
</s:schema>
</types>
<message name="ObtenirPrimaTotal_ProjecteRequest">
<part name="Login" type="s0:TString" />
<part name="Password" type="s0:TString" />
<part name="CodiMediador" type="s0:TString" />
<part name="DataEfecte" type="s0:TString" />
<part name="DataVenciment" type="s0:TString" />
<part name="FormaPagament" type="s0:TString" />
<part name="LlistaModalitats" type="s0:TAssociativeArrayList" />
<part name="LlistaRiscs" type="s0:TAssociativeArrayList" />
<part name="LlistaClausules" type="s0:TIntegerList" />
</message>
<message name="ObtenirPrimaTotal_ProjecteResponse">
<part name="CodiError" type="s0:TString" />
<part name="TexteError" type="s0:TString" />
<part name="PrimaNeta" type="s0:TFloat" />
<part name="PrimaNetaImpostos" type="s0:TFloat" />
<part name="PrimaNetaTotalRebut" type="s0:TFloat" />
<part name="PrimaAnual" type="s0:TFloat" />
<part name="PrimaAnualImpostos" type="s0:TFloat" />
<part name="PrimaAnualTotalRebut" type="s0:TFloat" />
</message>
<portType name="emisiowsdlPortType">
<operation name="ObtenirPrimaTotal_Projecte">
<documentation>Retorna la prima d'una plissa</documentation>
<input message="s0:ObtenirPrimaTotal_ProjecteRequest" />
<output message="s0:ObtenirPrimaTotal_ProjecteResponse" />
</operation>
</portType>
<binding name="emisiowsdlBinding" type="s0:emisiowsdlPortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="rpc" />
<operation name="ObtenirPrimaTotal_Projecte">
<soap:operation
soapAction="urn:emisiowsdl#ObtenirPrimaTotal_Proje cte" style="rpc" />
<input>
<soap:body use="encoded" namespace="urn:emisiowsdl"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output>
<soap:body use="encoded" namespace="urn:emisiowsdl"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
</operation>
</binding>
<service name="emisiowsdl">
<port name="emisiowsdlPort" binding="s0:emisiowsdlBinding">
<soap:address location="https://www.dummy.net:11110/WebService.php?webservice=emisio/server.php"
/>
</port>
</service>
</definitions>
************ WSDL ends here ***************
************ Response starts here ***********
<?xml version="1.0" encoding="ISO-8859-1"?>
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:si="http://soapinterop.org/xsd" xmlns:tns="urn:emisiowsdl">
<SOAP-ENV:Body>
<ns1:ObtenirPrimaTotal_ProjecteResponse
xmlns:ns1="urn:emisiowsdl">
<CodiError xsi:type="tns:TString">
</CodiError>
<TexteError xsi:type="tns:TString">
</TexteError>
<PrimaNeta xsi:type="tns:TFloat">30.89</PrimaNeta>
<PrimaNetaImpostos
xsi:type="tns:TFloat">1.94</PrimaNetaImpostos>
<PrimaNetaTotalRebut
xsi:type="tns:TFloat">32.83</PrimaNetaTotalRebut>
<PrimaAnual xsi:type="tns:TFloat">30.81</PrimaAnual>
<PrimaAnualImpostos
xsi:type="tns:TFloat">1.94</PrimaAnualImpostos>
<PrimaAnualTotalRebut
xsi:type="tns:TFloat">32.75</PrimaAnualTotalRebut>
</ns1:ObtenirPrimaTotal_ProjecteResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
************ Response ends here ***********

************** Exception Text starts here **************
System.InvalidOperationException: There is an error in XML document
(1, 541). ---> System.InvalidCastException: Cannot assign object of
type System.Xml.XmlNode[] to an object of type System.String.
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read5_ObtenirPrimaTotal_Projec teResponse()
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader
xmlReader, String encodingStyle)
at System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader
xmlReader)
at System.Web.Services.Protocols.SoapHttpClientProtoc ol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream, Boolean
asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtoc ol.Invoke(String
methodName, Object[] parameters)
at TestWrapperARAG.net.aragonline.www.emisiowsdl.ObtenirPrimaTotal_Projecte(String
Login, String Password, String CodiMediador, String DataEfecte, String
DataVenciment, String FormaPagament, TKeyValue[][] LlistaModalitats,
TKeyValue[][] LlistaRiscs, Int32[] LlistaClausules, String&
TexteError, Single& PrimaNeta, Single& PrimaNetaImpostos, Single&
PrimaNetaTotalRebut, Single& PrimaAnual, Single& PrimaAnualImpostos,
Single& PrimaAnualTotalRebut) in
d:\mtomas\projects\tarificador2.0\arag\testwrapper arag\referencias
web\net.aragonline.www\reference.cs:line 55
at TestWrapperARAG.Form1.button1_Click(Object sender, EventArgs e)
in d:\mtomas\projects\tarificador2.0\arag\testwrapper arag\form1.cs:line
134
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage (Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(M essage& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)
************** Exception Text ends here **************

Nov 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: bob scola | last post by:
I have a csharp, VS 2003 solution for a winform application The application uses an object called a "matter" and the class is defined in matter.cs. I can load matter objects into a combobox ...
6
by: Biva | last post by:
Hello All, Please help. I get the following error from my webpage: System.InvalidCastException: Specified cast is not valid. at Time.MaintAtRiskProjects.UpdateProject(String Project, String...
4
by: DOTNET | last post by:
Hi, Anybody help me regarding this error: I am assigning the values to the session variables when the button is clicked and passing these session variables to the next page and when I am...
0
by: JGKjr | last post by:
I have a Web Application written in C#. I am trying to call a web service method and recieve the error: System.InvalidCastException: Cannot assign object of type System.Boolean to an object of...
1
by: Parag Mahajan | last post by:
Hi, I am developing a .Net client for Axis 1.1 web service written in java. The wsdl is generated using, java2WSDL with these switches:: -y WRAPPED -u LITERAL The login service which returns a...
2
by: John Smith | last post by:
I'm writing webervice client using .Net 2.0. I have this class: public class MyWebService : SoapHttpClientProtocol { public XmlDocument validate(string url, XmlDocument xmlDocument) {...
1
by: sfindlay | last post by:
I have two comboboxes in an unbound field: - finds Vendor ID, and from this list finds Application ID using Vendor ID as the filter. The application details are populated in a subform bound...
8
by: Gamma | last post by:
I'm trying to inherit subclass from System.Diagnostics.Process, but whenever I cast a "Process" object to it's subclass, I encounter an exception "System.InvalidCastException" ("Specified cast is...
3
by: Promedeus | last post by:
.NET Version: 3.5 Ok, I recieve an error (System.InvalidCastException was unhandled. Message="Unable to cast object of type 'System.Windows.Forms.Control' to type 'System.Windows.Forms.Label'.")...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.