gpt4 book ai didi

soap - 使用经典的 asp 从 SOAP 服务获取简单的响应

转载 作者:行者123 更新时间:2023-12-05 08:24:32 26 4
gpt4 key购买 nike

我的任务是使用经典的 asp 从 SOAP 请求中获取响应。该请求几乎是最基本的——我只需要将 3 个参数发送到 Web 服务 URL 并写出响应(采用简单的纯文本格式)。我已经使用几个 SOAP 测试实用程序检查了该服务,它输出响应正常。

我还阅读了大约 10 个关于在经典 ASP 中使用 SOAP 提要的不同教程,但它们似乎根本不起作用。

我正在尝试的最新一个给了我以下代码:

<%
Set oXmlHTTP = CreateObject("Microsoft.XMLHTTP")
oXmlHTTP.Open "POST", "http://www.webservicehost.co.uk/B2bservice.asmx?wsdl", False

oXmlHTTP.setRequestHeader "Content-Type", "application/soap+xml; charset=utf-8"
oXmlHTTP.setRequestHeader "SOAPAction", "http://ourNameSpace/ourFunction"

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
%>

我拥有 POST URL、Ccode、Pword 和 OrderNo 变量的所有正确值,但不知道“SoapAction”或值使用什么。结果,当我运行该页面时,我得到了一个错误:

soap:SenderUnable to handle request without a valid action parameter。请提供有效的 SOAP 操作。

谁能建议 SoapAction 和 ourFunction xmlns 值使用什么?

非常感谢任何指点...

最佳答案

您的代码应该可以正常工作,只需进行一些更改

<%
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>"
%>

变化是

  • 删除 ?wdsl
  • 更改内容类型
  • 方法调用需要是 web 服务的同一服务器,因为它是方法名称

已添加

我在您提供 Web 服务时更改了代码。您在服务页面中所需要的一切:

alt text

original image here

用上面的代码回答:

alt text

关于soap - 使用经典的 asp 从 SOAP 服务获取简单的响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3905194/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com