ASP调用WEBSERVICE文档

2016-01-29 18:52 1 1 收藏

ASP调用WEBSERVICE文档,ASP调用WEBSERVICE文档

【 tulaoshi.com - ASP 】

 

----INDEX----
1. soap请求方式
2. post请求方式
3. SHOWALLNODE函数(关于节点各属性和数据显示)
---------------------
一.SOAP请求示例
下面是一个 SOAP 请求示例。所显示的占位符需要由实际值替换。
POST /WebService1/UserSignOn.asmx HTTP/1.1
Host: 192.100.100.81
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/LoginByAccount"

<?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
    <LoginByAccount xmlns="http://tempuri.org/"
      <usernamestring</username
      <passwordstring</password
    </LoginByAccount
  </soap:Body
</soap:Envelope
为了与WEBSERVICE交互,需要构造一个与上完全相同的SOAP请求:
<%
url = "http://192.100.100.81/WebService1/UserSignOn.asmx"

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"& _

"<LoginByAccount xmlns="&CHR(34)&"http://tempuri.org/"&CHR(34)&""& _
"<username"&username&"</username"& _
"<password"&password&"</password"& _
"</LoginByAccount"& _

"</soap:Body"& _
"</soap:Envelope"

Set xmlhttp = server.CreateObject("Msxml2.XMLHTTP")
xmlhttp.Open "POST",url,false
xmlhttp.setRequestHeader "Content-Type", "text/xml;charset=utf-8"
xmlhttp.setRequestHeader "HOST","192.100.100.81"
xmlhttp.setRequestHeader "Content-Length",LEN(SoapRequest)
xmlhttp.setRequestHeader "SOAPAction", "http://tempuri.org/LoginByAccount" ‘一定要与WEBSERVICE的命名空间相同,否则服务会拒绝
xmlhttp.Send(SoapRequest)
‘这样就利用XMLHTTP成功发送了与SOAP示例所符的SOAP请求.
‘检测一下是否成功:
Response.Write xmlhttp.Status&”&nbsp;”
Response.Write xmlhttp.StatusText
Set xmlhttp = Nothing
%
如果成功会显示200 ok,不成功会显示 500 内部服务器错误〿 Connection: keep-alive .
成功后就可以利用WEBSERVICE的响应,如下:
SOAP响应示例
下面是一个 SOAP 响应示例。所显示的占位符需要由实际值替换。
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/asp/)

<?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
    <LoginByAccountResponse xmlns="http://tempuri.org/"
      <LoginByAccountResultstring</LoginByAccountResult
    </LoginByAccountResponse
  </soap:Body
</soap:Envelope
这是与刚才SOAP请求示例所对应的SOAP响应示例,在成功发送请求后,就可以查看该响应 :
If xmlhttp.Status = 200 Then

Set xmlDOC =server.CreateObject("MSXML.DOMDocument")
xmlDOC.load(xmlhttp.responseXML)
xmlStr = xmlDOC.xml
Set xmlDOC=nothing
xmlStr = Replace(xmlStr,"<","&lt;")
xmlStr = Replace(xmlStr,"","&gt;")
Response.write xmlStr
Else

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/asp/)

Response.Write xmlhttp.Status&"&nbsp;"
Response.Write xmlhttp.StatusText

End if
请求正确则给出完整响应,请求不正确(如账号,密码不对)响应的内容就会信息不完整.
取出响应里的数据,如下:
If xmlhttp.Status = 200 Then

Set xmlDOC = server.CreateObject("MSX

来源:https://www.tulaoshi.com/n/20160129/1507590.html

延伸阅读
标签: ASP
       在ASP文件中调用DLL   作者:陈敏杰    动态联接库(DLL)是加快应用程序关键部分的执行速度的重要方法,但有一点恐怕大部分人都不知道,那就是在ASP文件也能通过调用DLL来加快服务器的执行速度,下面我简单的介绍一下在ASP文件调用DLL的步骤。    首先,必须...
标签: ASP
  调用数据库存储过程 <%Set Dataconn = Server.CreateObject("ADODB.Connection") '建立连接对象 Dataconn.Open "DSN=SinoTrans;SERVER=APP_SERVER;UID=sa;PWD=;APP=Microsoft(R) Developer Studio;WSID=APP_SERVER;Regional=Yes" Set cmdTemp = Server.CreateObject("ADODB.Command") '建立命令对象 ...
标签: ASP
      在安全性要求不是很高的ASP.Net程序中,基于Forms的身份验证是经常使用的一种方式,而如果需要对WebService进行身份验证,最常用的可能是基于Soap 标头的自定义身份验证方式。如果对两者做一下比较的话,显然,基于Forms的验证方式更加方便易用,能否将Forms验证方式应用到WebService中去呢?     ...
本示例和参考文章的差别在于: 1)deploy.wsdd定义的更详细(对于server端定义了接口:ICalculate): 代码如下: deployment xmlns="http://xml.apache.org/axis/wsdd/"     xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"     service name="Calculate" provider="java:RPC" style="rpc" u...
标签: ASP
  从ASP调用SQL中的图像 eNet学院 关键词:Sql Server, ADO 如何处理ASP中的图象 在用ASP编程中,很多时侯要用到图象。对于单纯从数据库中处理一个图象,方法大家讲了很多,也不难, 可以看下面的代码: 这里假设你有个数据库名字叫:PUBS,在数据库中有一个叫:PUB_INFO的表,在表中有一个LOGO 的BLOB列。我们查出PUB_ID=0736的...

经验教程

266

收藏

19
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部