使用经典的asp从SOAP服务获得简单的响应

Dan*_*Dan 1 soap asp-classic

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

我还阅读了10篇关于在经典ASP中使用SOAP feed的不同教程,但它们似乎都没有.

我正在尝试的最新版本给了我以下代码:

<%
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
%>
Run Code Online (Sandbox Code Playgroud)

我有POST URL,Ccode,Pword和OrderNo变量的所有正确值,但不知道用于"SoapAction"或值的内容.结果,当我运行页面时,我收到一个错误:

soap:SenderUnable在没有有效action参数的情况下处理请求.请提供有效的肥皂行动.

任何人都可以建议使用SoapAction和ourFunction xmlns值吗?

非常感谢任何指针......

bal*_*dre 11

您的代码应该可以通过一些更改正常工作

<%
    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>"
%>
Run Code Online (Sandbox Code Playgroud)

变化是

  • 去掉 ?wdsl
  • 更改内容类型
  • 方法调用需要与Web服务的服务器相同,因为它是方法名称

添加

我在提供Web服务时更改了代码.您只需要在服务页面中拥有:

替代文字

原始图片在这里

回答上面的代码:

替代文字