以下是來自http://stackoverflow.com/questions/3905194/get-simple-response-from-soap-service-with-classic-asp的範例圖片 ,查閱asmx web service所提供的網址,可以取得請求的XML範例,但Classic ASP要如何建立對應的程式碼?這個圖片提供了對應的說明。
- Using SOAP in HTTP :
- Simple Object Access Protocol (SOAP) 1.1 :
http://www.w3.org/TR/2000/NOTE-SOAP-20000508/ - Using SOAP in HTTP :
http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383526 - 關於XMLHTTP的一些基本介紹:http://zh.wikipedia.org/wiki/XMLHTTP
- w3school關於XmlHttpRequest的說明:
http://www.w3school.com.cn/xmldom/dom_http.asp - 關於XMLHttpRequest物件的規格說明:http://www.w3.org/TR/XMLHttpRequest/
- open 方法說明
open(method, url [,async=true [,user=null [,password=null]]])
method可用選項CONNECT, DELETE, GET, HEAD, OPTIONS, POST, PUT, TRACE, or TRACK
async=true非同步, false同步 - setRequestHeader方法說明
setRequestHeader(header, value)
header可用大類:Accept-Charset, Accept-Encoding, Access-Control-Request-Headers, Access-Control-Request-Method, Connection, Content-Length, Cookie, Cookie2, Date, DNT, Expect, Host, Keep-Alive, Origin, Referer, TE, Trailer, Transfer-Encoding, Upgrade, User-Agent, Via, ... ,例如:
"Content-Type", "text/xml; charset=utf-8"
"SOAPAction", "http://提供soap服務的url/要請求內容的方法" - send方法說明:送出請求
send([data = null])
如果請求的方法用GET或HEAD,不需傳遞data參數 - responseType屬性說明:
response.Type的屬性值:空字串(預設), "arraybuffer", "blob", "document", "json", 及 "text". - responseText屬性
- responseXML屬性
<%
Response.Write "<br>START<hr>"
Set oXmlHTTP = CreateObject("Microsoft.XMLHTTP")
oXmlHTTP.Open "POST", "http://www.crusaderb2b.co.uk/b2bservice.asmx", False
oXmlHTTP.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
oXmlHTTP.setRequestHeader "SOAPAction", "http://crusaderb2b.co.uk/TrackingId"
SOAPRequest = _
"<?xml version=""1.0"" encoding=""utf-8""?>" &_
"<soap12:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap12=""http://www.w3.org/2003/05/soap-envelope"">" &_
"<soap12:Body>" &_
"<ourFunction xmlns=""http://ourNameSpace/"">" &_
"<Ccode>OurCode</Ccode>" &_
"<Pword>1d2s45a</Pword>" &_
"<OrderNo>9876</OrderNo>" &_
"</ourFunction>" &_
"</soap12:Body>" &_
"</soap12:Envelope>"
oXmlHTTP.send SOAPRequest
Response.Write oXmlHTTP.responseText
Response.Write "<br>END<hr>"
%>
沒有留言:
張貼留言