C#SOAP Web服务方法返回null



我在C#项目上从SOAP Web服务调用一个方法,尽管我可以在程序级别看到带有预期数据和格式(使用fiddler(的响应,但该方法返回null。可能是函数没有正确解析响应吗?

该函数以标准方式调用(selectedPLCInfo最终为空(

LanDB.DeviceBasicInfo selectedPLCInfo = client.getDeviceBasicInfo(plcHostname);

这是应用程序发送的请求:

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>

这就是回应:

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>

你知道为什么会发生这种事吗?

谢谢!

解决方案是将服务添加为Web引用,而不是服务引用。此处提供更多信息:

http://webservices20.blogspot.com/2008/10/interoperability-gotcha-visual-studio.html

相关内容

  • 没有找到相关文章

最新更新