C# SOAP Webservice method returns null
I’m calling a method from a SOAP webservice on a C# project and even though I can see the response arriving with the expected data and format (using fiddler) at the program level the method returns null. Can it be that the function is not properly parsing the response, somehow?
The function is called in standard way (selectedPLCInfo ends up as null)
LanDB.DeviceBasicInfo selectedPLCInfo = client.getDeviceBasicInfo(plcHostname);
This is the request being sent by the application:
POST xxx/soap/soap.fcgi?v=6 HTTP/1.1 Content-Type: text/xml; charset=utf-8 SOAPAction: "" Host: xxx Content-Length: 1439 Expect: 100-continue Accept-Encoding: gzip, deflate <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Header> <Auth xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <token xmlns="http://schemas.datacontract.org/2004/07/TIA_Portal_VPG_Manager">token</token> </Auth> </s:Header> <s:Body s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <q1:getDeviceBasicInfo xmlns:q1="urn:NetworkService"><DeviceName xsi:type="xsd:string">CFP-RE12-VLHCPFM2</DeviceName></q1:getDeviceBasicInfo></s:Body> </s:Envelope>
And this is the response:
HTTP/1.1 200 OK Date: Fri, 10 Jul 2020 10:15:17 GMT Server: Apache SOAPServer: SOAP060::Lite/Perl/0.60 Content-Length: 2912 Content-Type: text/xml; charset=utf-8 <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:types="urn:NetworkDataTypes" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Body> <namesp3945:getDeviceBasicInfoResponse xmlns:namesp3945="urn:NetworkService"> <DeviceBasicInfo xsi:type="types:DeviceInfo"> (... a ton of expected data here) </DeviceBasicInfo> </namesp3945:getDeviceBasicInfoResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
Any ideas why this might be happening?
Thanks!
The solution was to add the service as a Web Reference instead of Service Reference. Further information here:
http://webservices20.blogspot.com/2008/10/interoperability-gotcha-visual-studio.html