GetRats
测试
测试窗体只能用于来自本地计算机的请求。
SOAP 1.1
以下是 SOAP 1.2 请求和响应示例。所显示的占位符需替换为实际值。
POST /XXY/Service.asmx HTTP/1.1
Host: 192.168.1.224
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/GetRats"
<?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>
<GetRats xmlns="http://tempuri.org/">
<strmd5>string</strmd5>
</GetRats>
</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>
<GetRatsResponse xmlns="http://tempuri.org/">
<GetRatsResult>string</GetRatsResult>
</GetRatsResponse>
</soap:Body>
</soap:Envelope>
就这个,怎么写代码查询服务器上的数据? .net 和xml不是很懂
进入VS解决方案,在解决方案管理器
中的要使用以上SOAP的项目右键,选择添加
中的服务引用
弹出一个添加服务引用
的窗口,地址
填写你需要连接的SOAP的地址,一般格式为xxxxxxxxx.asmx(前面的xxx代指网络路径,一定以.asmx结尾,例如http://www.webservicex.net/globalweather.asmx
,当然我只是举个天气服务的例子)
给你的服务引用取个名字,以后这个服务引用就成为你本项目使用的一个服务引用的命名空间,比如我上面例子中的天气服务,起名为GloWea
首先new
一个SoapClient
的对象出来,还是以天气服务为例:
GloWea.GlobalWeatherSoapClient cli = new GloWea.GlobalWeatherSoapClient();
然后使用这个SoapClient对象调用服务引用中的方法,还是以天气服务为例:
String str = cli.GetWeather("chongqing", "china");
Console.WriteLine(str);
题主先按照以上的流程添加自己需要的那个服务引用,若还不能解决,可继续追问;若解决了您的问题,请采纳。
按你说的加了,然后怎么写代码?
WebTTReference.ServiceSoapClient cli = new WebTTReference.ServiceSoapClient();
String str = cli.GetRats("11115353");
Console.WriteLine(str);