我想从此网络服务向方法SalePaymentRequest
发送数据,但我不知道在哪里放置SalePaymentRequest
方法的名称:
https://pec.shaparak.ir/NewIPGServices/Sale/SaleService.asmx
这是我在Classic ASP / VBScript中的代码:
amount = 1000
id = 1
pin = "mypincode"
posturl = "https://pec.shaparak.ir/NewIPGServices/Sale/SaleService.asmx"
backurl = "mywebsite/back.asp"
DataToSend = "LoginAccount=" & pin & "&Amount=" & amount & "&OrderId="& id & "&CallBackUrl="&backurl
Dim xmlhttp
Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.Open "POST", posturl, False
xmlhttp.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlhttp.Send DataToSend
Response.Write xmlhttp.ResponseText
Set xmlhttp = Nothing
答案 0 :(得分:0)
通过引用Web服务的documentation,我发现帖子应该是SOAP请求,并且为了访问SalePaymentRequest
方法,服务本身引入了一个SOPAction URL。我不得不将SOAP发布到该URL。 SOAP文档的格式完全由服务文档定义:
pin = "mypincode"
posturl = "https://pec.shaparak.ir/NewIPGServices/Sale/SaleService.asmx"
backurl = "mywebsite/back.asp"
'///This is the exact answer to my question! This URL defines the method target:
SOAPAction ="https://pec.Shaparak.ir/NewIPGServices/Sale/SaleService/SalePaymentRequest"
soap="<?xml version=""1.0"" encoding=""utf-8""?>"
soap=soap& "<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=soap& "<soap:Body>"
soap=soap& "<SalePaymentRequest xmlns=""https://pec.Shaparak.ir/NewIPGServices/Sale/SaleService"">"
soap=soap& "<requestData>"
soap=soap& "<LoginAccount>" & pin & "</LoginAccount>"
soap=soap& "<Amount>" & amount &"</Amount>"
soap=soap& "<OrderId>"& id &"</OrderId>"
soap=soap& "<CallBackUrl>"& backurl &"</CallBackUrl>"
soap=soap& "</requestData>"
soap=soap& "</SalePaymentRequest>"
soap=soap& "</soap:Body>"
soap=soap& "</soap:Envelope>"
dim xmlhttp
set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")
xmlhttp.Open "POST",posturl,false
xmlhttp.setRequestHeader "Content-Type", "text/xml"
xmlhttp.setRequestHeader "SOAPAction", SOAPAction
xmlhttp.send soap
Response.Write xmlhttp.responseText
Set xmlhttp = nothing