简体   繁体   English

C# SOAP Webservice方法返回null

[英]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.我正在从 C# 项目上的 SOAP Web 服务调用一个方法,即使我可以在程序级别看到带有预期数据和格式(使用提琴手)的响应,该方法仍返回 Z37A6259CC0C1DAE0BDFFFFF786648。 Can it be that the function is not properly parsing the response, somehow?莫非 function 没有正确解析响应?

The function is called in standard way (selectedPLCInfo ends up as null) function 以标准方式调用(selectedPLCInfo 最终为空)

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.解决方案是将服务添加为 Web 参考而不是服务参考。 Further information here:更多信息在这里:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM