Error using RPC / encoded SOAP web service in .NET.

When calling the web service method, I get the following error.

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

A web service is a PHP service. I created my proxy class using wsdl.exe from the wsdl document defined here. http://webservice.intelecast.com.au/traffic/PublicSoap/server.php?wsdl

The following is the proxy client method that I am calling.

[System.Web.Services.Protocols.SoapRpcMethodAttribute("http://webservice.intelecast.com.au/traffic/PublicSoap/server.php#getAllTraffic", RequestNamespace="http://webservice.intelecast.com.au/traffic/PublicSoap/server.php", ResponseNamespace="http://webservice.intelecast.com.au/traffic/PublicSoap/server.php")] [return: System.Xml.Serialization.SoapElementAttribute("return")] public TmcInfo[] getAllTmcTraffic(string[] States, int[] EventCodes) { object[] results = this.Invoke("getAllTmcTraffic", new object[] { //Error here States, EventCodes}); 

It seems that the proxy class cannot handle the complex types / arrays defined in wsdl ... I am not sure that now, as I continue, I can’t find a solution on the Internet anywhere.

Below is the SOAP response I get. It all seems valid.

 <?xml version="1.0" encoding="iso-8859-1"?> <SOAP-ENV:Envelope 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:tns="http://webservice.intelecast.com.au/traffic/PublicSoap/server.php"> <SOAP-ENV:Body> <ns1:getAllTrafficResponse xmlns:ns1="http://webservice.intelecast.com.au/traffic/PublicSoap/server.php"> <return xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="tns:TrafficInfo[2]"> <item xsi:type="tns:TrafficInfo"> <id xsi:type="xsd:string">1245632068110</id> <entryDate xsi:type="xsd:datetime">22/06/2009 10:54:28</entryDate> <direction xsi:type="xsd:int">0</direction> <extent xsi:type="xsd:int">1</extent> <locationCode xsi:type="xsd:int">31593</locationCode> <countryCode xsi:type="xsd:int">4</countryCode> <ltn xsi:type="xsd:int">56</ltn> <diversionAdvice xsi:type="xsd:int">0</diversionAdvice> <slAdvice xsi:type="xsd:int">0</slAdvice> <quantifier xsi:type="xsd:int">0</quantifier> <suppInfoCode xsi:type="xsd:int">0</suppInfoCode> <addEvent xsi:type="xsd:int">0</addEvent> <detDivAdvice xsi:type="xsd:int">0</detDivAdvice> <destinations xsi:type="xsd:int">0</destinations> <clSourceProblem xsi:type="xsd:int">0</clSourceProblem> <eventCode xsi:type="xsd:int">802</eventCode> <timeInfo xsi:type="tns:TimeInfo"> <start xsi:type="xsd:string">21/06/2009 14:00:00</start> <finish xsi:type="xsd:string">05/11/2009 14:00:00</finish> <timeZone xsi:type="xsd:string">Australia/Brisbane</timeZone> </timeInfo> <location xsi:type="tns:Point"> <lat xsi:type="xsd:float">-27.3112692120521</lat> <lon xsi:type="xsd:float">153.029100894928</lon> </location> <additionalStreetInfo xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="tns:AdditionalStreetInfo[1]"> <item xsi:type="tns:AdditionalStreetInfo"> <street xsi:type="xsd:string">Bracken Ridge Rd</street> <type xsi:type="xsd:string">CROSS</type> </item> </additionalStreetInfo> <address xsi:type="tns:Address"> <streetNumber xsi:type="xsd:string"/> <streetName xsi:type="xsd:string">Bracken Ridge Rd</streetName> <suburb xsi:type="xsd:string">Bracken Ridge</suburb> <state xsi:type="xsd:string">QLD</state> </address> </item> <item xsi:type="tns:TrafficInfo"> <id xsi:type="xsd:string">1245632111995</id> <entryDate xsi:type="xsd:datetime">22/06/2009 10:55:11</entryDate> <direction xsi:type="xsd:int">1</direction> <extent xsi:type="xsd:int">1</extent> <locationCode xsi:type="xsd:int">31592</locationCode> <countryCode xsi:type="xsd:int">4</countryCode> <ltn xsi:type="xsd:int">56</ltn> <diversionAdvice xsi:type="xsd:int">0</diversionAdvice> <slAdvice xsi:type="xsd:int">0</slAdvice> <quantifier xsi:type="xsd:int">0</quantifier> <suppInfoCode xsi:type="xsd:int">0</suppInfoCode> <addEvent xsi:type="xsd:int">0</addEvent> <detDivAdvice xsi:type="xsd:int">0</detDivAdvice> <destinations xsi:type="xsd:int">0</destinations> <clSourceProblem xsi:type="xsd:int">0</clSourceProblem> <eventCode xsi:type="xsd:int">802</eventCode> <timeInfo xsi:type="tns:TimeInfo"> <start xsi:type="xsd:string">21/06/2009 14:00:00</start> <finish xsi:type="xsd:string">05/11/2009 14:00:00</finish> <timeZone xsi:type="xsd:string">Australia/Brisbane</timeZone> </timeInfo> <location xsi:type="tns:Point"> <lat xsi:type="xsd:float">-27.3125370752656</lat> <lon xsi:type="xsd:float">153.042898178101</lon> </location> <additionalStreetInfo xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="tns:AdditionalStreetInfo[1]"> <item xsi:type="tns:AdditionalStreetInfo"> <street xsi:type="xsd:string">Bracken Ridge Rd</street> <type xsi:type="xsd:string">CROSS</type> </item> </additionalStreetInfo> <address xsi:type="tns:Address"> <streetNumber xsi:type="xsd:string"/> <streetName xsi:type="xsd:string">Bracken Ridge Rd</streetName> <suburb xsi:type="xsd:string">Bracken Ridge</suburb> <state xsi:type="xsd:string">QLD</state> </address> </item> </return> </ns1:getAllTrafficResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope> 
+2
source share
2 answers

Is this an error in wsdl.exe? I have some nasty encounters with wsdl.exe . Here are the problems outlined in my post:

The first problem he cannot handle is the sequence with a complex element. You will think that today webservice environment, the sequence of complex elements are the norm. But obviously, Microsoft does not think so, and this leads to the inability of wsdl.exe to process a sequence of complex elements.

What if you insist on using wsdl.exe to generate a proxy class for an element with a sequence of complex types? You will receive a critical exception: it is impossible to import the binding * from the namespace * - the operation failed to import * - the data type is missing. The second wsdl error is that it is not permissible to have two web methods that have the same reverse signature. Yes, if one method returns a ComplexType type, the other methods must have a different return type. failure of this will result in a System.InvalidOperationException: XML element * from namespace * refers to method references and type exceptions.

Please note that in both cases the messages are cryptic. You really do not know what is happening behind the hood. And also this is the most unpleasant of all. You don’t know if you didn’t work because the tool is lousy, or because you are not doing everything right.

Perhaps you can refer to this post for an alternative to wsdl.exe.

+1
source

It is worth noting that the implementation of SOAP in rpc / encoded has problems with complex types. One way to solve this problem is to convert the WSDL format to Document / Literal format.

0
source

Source: https://habr.com/ru/post/1345638/


All Articles