在经典 ASP 中使用 SOAP Web 服务 [英] consuming SOAP web services in classic ASP

查看:25
本文介绍了在经典 ASP 中使用 SOAP Web 服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对此代码有疑问:

Set oXmlHTTP = CreateObject("Microsoft.XMLHTTP")
oXmlHTTP.Open "POST", "http://www.oursite.com/WebServices/ourService.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/"">" &_
        "<var1>" & Session("userid") & "</var1>" &_
        "<var2>" & Session("internetid") & "</var2>" &_
      "</ourFunction>" &_
    "</soap12:Body>" &_
  "</soap12:Envelope>"

oXmlHTTP.send SOAPRequest

它执行并没有出错,但我找不到任何输出,或者即使它存在我也无法解析它 - 但在这两种情况下我都不知道它.

It executes and gives no error, but I can't find any output, or I can't parse it even if it exists - but in both cases I don't know about it.

调用后,我应该如何解析返回的 XML?

After doing the call, how am I supposed to get the parsing of returned XML?

推荐答案

你错过了:

Set xmlResp = oXmlHTTP.responseXML

这使您可以访问 Msxml2.DOMDocument 对象.您如何从中获取数据实际上取决于您的肥皂响应的格式.

This gives you access to an Msxml2.DOMDocument object. How you get the data from that really depends on the format of your soap response.

它应该看起来像这样:

<%    Set nodes = xmlResp.getElementsByTagName("returnVal") %>
<ul>
<%    For Each node in nodes    %> 
   <li><%=node.text%></li>
<%    Next    %>
</ul>

另见:

这篇关于在经典 ASP 中使用 SOAP Web 服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆