小编rit*_*ita的帖子

SOAP xml客户端 - 使用Visual Studio 2010 c# - 如何?

我是.NET世界的新手,但必须使用VStudio C#2010(.NET 4.0)来生成以SOAP Xml方式从Web服务请求数据的客户端.我在这里寻找答案,但更加困惑.MSDN表示"构建XML Web服务客户端"是.NET 4.0的遗产,即WSDL是遗留的.他们说,使用"WCF".在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>
Run Code Online (Sandbox Code Playgroud)

响应:

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>
Run Code Online (Sandbox Code Playgroud)

那么,构建这个简单客户端的正确方法,或者至少是最合理的方式是什么?您会向新手建议哪些工具/库/方法(假设是VS 2010 C#,.NET 4.0环境)?

c# wcf soap .net-4.0

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

.net-4.0 ×1

c# ×1

soap ×1

wcf ×1