ASP如何调用。Net的WebService
来源:互联网 发布:淘宝刷单一个月赚3000 编辑:程序博客网 时间:2024/04/28 19:03
ASP调用.Net的webservice的例子:
假设webservice的地址是http://192.168.0.88/test.asmx 接口是doAdd
下面是WebService的 SOAP 请求和响应示例
POST /test.asmx HTTP/1.1
Host: 192.168.0.88
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://www.test.com/doAdd"
<?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>
<doAdd xmlns="http://www.test.com">
<sRequest>string</sRequest>
</doAdd>
</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>
<doAddResponse xmlns="http://www.test.com">
<doAddResult>string</doAddResult>
</doAddResponse>
</soap:Body>
</soap:Envelope>
下面是ASP页面:test.asp
<%
Dim url,xmlhttp,dom,node,xmlDOC
'根据webservice的测试页,构造不同的soap request
SoapRequest = "<?xml version="&CHR(34)&"1.0"&CHR(34)&" encoding="&CHR(34)&"utf-8"&CHR(34)&"?>"&_
"<soap:Envelope xmlns:xsi="&CHR(34)&"http://www.w3.org/2001/XMLSchema-instance"&CHR(34)&" xmlns:xsd="&CHR(34)&"http://www.w3.org/2001/XMLSchema"&CHR(34)&" xmlns:soap="&CHR(34)&"http://schemas.xmlsoap.org/soap/envelope/"&CHR(34)&">"&_
"<soap:Body>"&_
"<queryCardInfo xmlns="&CHR(34)&"http://tempuri.org/"&CHR(34)&">"&_
"<nCardID>0</nCardID>"&_
"<nAmt>1</nAmt>"&_
"</queryCardInfo>"&_
"</soap:Body>"&_
"</soap:Envelope>"
url = "http://192.168.0.88/test.asmx?op=doAdd"
Set xmlDOC =CreateObject("MSXML.DOMDocument")
xmlDOC.loadXML(SoapRequest)
Set xmlhttp = CreateObject("Msxml2.XMLHTTP")
xmlhttp.Open "POST",url,false
xmlhttp.setRequestHeader "Content-Type", "text/xml;charset=utf-8"
'SOAPAction这个Header头同样可以在sample中找到
xmlhttp.setRequestHeader "SOAPAction", "http://tempuri.org/queryCardInfo"
xmlhttp.setRequestHeader "Content-Length",LEN(SoapRequest)
xmlhttp.Send(xmlDOC)
response.write "status = "&xmlhttp.Status&"<br>"
response.write "statustxt = "&xmlhttp.StatusText&"<br>"
response.write "responseText = "&xmlhttp.responseText&"<br>"
If xmlhttp.Status = 200 Then 'ok responseXML
xmlDOC.load(xmlhttp.responseXML)
'response.write "price = "&xmlDOC.getElementsByTagName("PARAMS").item(0).xml&"<br>"
response.Write(xmlDOC.xml)
else
response.write "failed"
end if
%>
- ASP如何调用。Net的WebService
- jQuery如何调用ASP.NET的WebService
- asp.net如何调用 webservice
- Asp.Net Ajax 如何调用WebService
- 如何动态调用asp.net Webservice
- ASP.NET如何定时调用WebService服务
- ASP调用.net webservice
- asp.net调用WebService
- Asp.net调用webservice
- Asp.net调用webservice
- jQuery调用ASP.NET的WebService
- asp.net调用java写的webservice
- Android客户端调用Asp.net的WebService
- Android 调用 Asp.net 的WebService 实例
- Android客户端调用Asp.net的WebService
- Android客户端调用Asp.net的WebService
- JAVA如何调用.NET开发的WebService
- .NET3.5下Asp.net如何异步调用WebService
- Linux 内核配置系统浅析
- ASP调用.Net编写的动态库(DLL)
- 嵌入式系统
- Dot Net设计模式—MVC模式
- 如何正确使用ads
- ASP如何调用。Net的WebService
- s3c44b0x uclinux2.4.19移植
- ASP技术--RegExp对象正则表达式功能用法
- 一道小题
- 美国市场是市场开发成本最小,最稳定的财源
- 嵌入式设备上的 Linux 系统开发
- Google排名——搜索引擎登记技巧
- RHEL4U2 升级mysql的问题及解决
- 但愿她不会从此换掉QQ