我是.NET世界的新手,但必须使用VStudio C# 2010(.NET 4.0)以SOAP Xml方式从Web服务请求数据。我在这里搜索答案,但更加困惑了。MSDN表示,“创建XML Web服务客户端”对于.NET 4.0是遗留问题,即WSDL是遗留问题。他们说要使用“WCF”代替。
在WCF中,我迷失了——太多而且太模糊了。它肯定比那简单…
我能在网上找到的所有示例都使用WSDL,“遗留技术”。
这里是我需要使用的服务定义,以便从Web服务获取数据:
请求:
在WCF中,我迷失了——太多而且太模糊了。它肯定比那简单…
我能在网上找到的所有示例都使用WSDL,“遗留技术”。
这里是我需要使用的服务定义,以便从Web服务获取数据:
请求:
POST /catalog.asmx HTTP/1.1
Host: www.somewebsite.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "https://www.somewebsite.com/KeywordSearch"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<KeywordSearch xmlns="https://www.somewebsite.com/">
<searchTerm>string</searchTerm>
<resultsReturned>int</resultsReturned>
</KeywordSearch>
</soap:Body>
</soap:Envelope>
响应:
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
...some stuff...
</soap:Body>
</soap:Envelope>
那么,构建这个简单客户端的正确或至少最合乎逻辑的方式是什么?您建议新手使用哪些工具/库/方法(假设使用VS 2010 C#,.NET 4.0环境)?