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.Invalid OperationExcept ion: There is an error in XML
document (1, 541). ---> System.InvalidC astException: Cannot assign
object of type System.Xml.XmlN ode[] 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="htt p://schemas.xmlsoap .org/wsdl/http/"
xmlns:soap="htt p://schemas.xmlsoap .org/wsdl/soap/"
xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:s0="urn:e misiowsdl"
xmlns:soapenc=" http://schemas.xmlsoap .org/soap/encoding/"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:mime="htt p://schemas.xmlsoap .org/wsdl/mime/"
targetNamespace ="urn:emisiowsd l"
xmlns="http://schemas.xmlsoap .org/wsdl/">
<types>
<s:schema targetNamespace ="urn:emisiowsd l">
<s:import namespace="http ://schemas.xmlsoap .org/soap/encoding/"
/>
<s:import namespace="http ://schemas.xmlsoap .org/wsdl/" />
<s:complexTyp e name="TIntegerL ist">
<s:complexConte nt mixed="false">
<s:restrictio n base="soapenc:A rray">
<s:attribute d7p1:arrayType= "s0:TIntege r[]"
ref="soapenc:ar rayType" xmlns:d7p1="htt p://schemas.xmlsoap .org/wsdl/"
/>
</s:restriction>
</s:complexConten t>
</s:complexType>
<s:complexTyp e name="TKeyValue ">
<s:all>
<s:element name="key" type="s:string" />
<s:element name="value" type="s:string" />
</s:all>
</s:complexType>
<s:complexTyp e name="TAssociat iveArray">
<s:complexConte nt mixed="false">
<s:restrictio n base="soapenc:A rray">
<s:attribute d7p1:arrayType= "s0:TKeyVal ue[]"
ref="soapenc:ar rayType" xmlns:d7p1="htt p://schemas.xmlsoap .org/wsdl/"
/>
</s:restriction>
</s:complexConten t>
</s:complexType>
<s:complexTyp e name="TAssociat iveArrayList">
<s:complexConte nt mixed="false">
<s:restrictio n base="soapenc:A rray">
<s:attribute d7p1:arrayType= "s0:TAssociativ eArray[]"
ref="soapenc:ar rayType" xmlns:d7p1="htt p://schemas.xmlsoap .org/wsdl/"
/>
</s:restriction>
</s:complexConten t>
</s:complexType>
<s:simpleType name="TString">
<s:restrictio n base="s:string" />
</s:simpleType>
<s:simpleType name="TInteger" >
<s:restrictio n base="s:int" />
</s:simpleType>
<s:simpleType name="TFloat">
<s:restrictio n base="s:float" />
</s:simpleType>
</s:schema>
</types>
<message name="ObtenirPr imaTotal_Projec teRequest">
<part name="Login" type="s0:TStrin g" />
<part name="Password" type="s0:TStrin g" />
<part name="CodiMedia dor" type="s0:TStrin g" />
<part name="DataEfect e" type="s0:TStrin g" />
<part name="DataVenci ment" type="s0:TStrin g" />
<part name="FormaPaga ment" type="s0:TStrin g" />
<part name="LlistaMod alitats" type="s0:TAssoc iativeArrayList " />
<part name="LlistaRis cs" type="s0:TAssoc iativeArrayList " />
<part name="LlistaCla usules" type="s0:TInteg erList" />
</message>
<message name="ObtenirPr imaTotal_Projec teResponse">
<part name="CodiError " type="s0:TStrin g" />
<part name="TexteErro r" type="s0:TStrin g" />
<part name="PrimaNeta " type="s0:TFloat " />
<part name="PrimaNeta Impostos" type="s0:TFloat " />
<part name="PrimaNeta TotalRebut" type="s0:TFloat " />
<part name="PrimaAnua l" type="s0:TFloat " />
<part name="PrimaAnua lImpostos" type="s0:TFloat " />
<part name="PrimaAnua lTotalRebut" type="s0:TFloat " />
</message>
<portType name="emisiowsd lPortType">
<operation name="ObtenirPr imaTotal_Projec te">
<documentation> Retorna la prima d'una plissa</documentation>
<input message="s0:Obt enirPrimaTotal_ ProjecteRequest " />
<output message="s0:Obt enirPrimaTotal_ ProjecteRespons e" />
</operation>
</portType>
<binding name="emisiowsd lBinding" type="s0:emisio wsdlPortType">
<soap:binding transport="http ://schemas.xmlsoap .org/soap/http"
style="rpc" />
<operation name="ObtenirPr imaTotal_Projec te">
<soap:operati on
soapAction="urn :emisiowsdl#Obt enirPrimaTotal_ Projecte" 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="emisiowsd l">
<port name="emisiowsd lPort" binding="s0:emi siowsdlBinding" >
<soap:address location="https ://www.dummy.net:1 1110/WebService.php? webservice=emis io/server.php"
/>
</port>
</service>
</definitions>
************ WSDL ends here ***************
************ Response starts here ***********
<?xml version="1.0" encoding="ISO-8859-1"?>
<SOAP-ENV:Envelope SOAP-ENV:encodingSty le="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:ObtenirPri maTotal_Project eResponse
xmlns:ns1="urn: emisiowsdl">
<CodiError xsi:type="tns:T String">
</CodiError>
<TexteError xsi:type="tns:T String">
</TexteError>
<PrimaNeta xsi:type="tns:T Float">30.89</PrimaNeta>
<PrimaNetaImpos tos
xsi:type="tns:T Float">1.94</PrimaNetaImpost os>
<PrimaNetaTotal Rebut
xsi:type="tns:T Float">32.83</PrimaNetaTotalR ebut>
<PrimaAnual xsi:type="tns:T Float">30.81</PrimaAnual>
<PrimaAnualImpo stos
xsi:type="tns:T Float">1.94</PrimaAnualImpos tos>
<PrimaAnualTota lRebut
xsi:type="tns:T Float">32.75</PrimaAnualTotal Rebut>
</ns1:ObtenirPrim aTotal_Projecte Response>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
************ Response ends here ***********
************** Exception Text starts here **************
System.InvalidO perationExcepti on: There is an error in XML document
(1, 541). ---> System.InvalidC astException: Cannot assign object of
type System.Xml.XmlN ode[] to an object of type System.String.
at Microsoft.Xml.S erialization.Ge neratedAssembly .XmlSerializati onReader1.Read5 _ObtenirPrimaTo tal_ProjecteRes ponse()
--- End of inner exception stack trace ---
at System.Xml.Seri alization.XmlSe rializer.Deseri alize(XmlReader
xmlReader, String encodingStyle)
at System.Xml.Seri alization.XmlSe rializer.Deseri alize(XmlReader
xmlReader)
at System.Web.Serv ices.Protocols. SoapHttpClientP rotocol.ReadRes ponse(SoapClien tMessage
message, WebResponse response, Stream responseStream, Boolean
asyncCall)
at System.Web.Serv ices.Protocols. SoapHttpClientP rotocol.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[][] LlistaModalitat s,
TKeyValue[][] LlistaRiscs, Int32[] LlistaClausules , String&
TexteError, Single& PrimaNeta, Single& PrimaNetaImpost os, Single&
PrimaNetaTotalR ebut, Single& PrimaAnual, Single& PrimaAnualImpos tos,
Single& PrimaAnualTotal Rebut) in
d:\mtomas\proje cts\tarificador 2.0\arag\testwr apperarag\refer encias
web\net.aragonl ine.www\referen ce.cs:line 55
at TestWrapperARAG .Form1.button1_ Click(Object sender, EventArgs e)
in d:\mtomas\proje cts\tarificador 2.0\arag\testwr apperarag\form1 .cs:line
134
at System.Windows. Forms.Control.O nClick(EventArg s e)
at System.Windows. Forms.Button.On Click(EventArgs e)
at System.Windows. Forms.Button.On MouseUp(MouseEv entArgs mevent)
at System.Windows. Forms.Control.W mMouseUp(Messag e& m, MouseButtons
button, Int32 clicks)
at System.Windows. Forms.Control.W ndProc(Message& m)
at System.Windows. Forms.ButtonBas e.WndProc(Messa ge& m)
at System.Windows. Forms.Button.Wn dProc(Message& m)
at System.Windows. Forms.ControlNa tiveWindow.OnMe ssage(Message& m)
at System.Windows. Forms.ControlNa tiveWindow.WndP roc(Message& m)
at System.Windows. Forms.NativeWin dow.Callback(In tPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)
************** Exception Text ends here **************