soap - 使用经典 ASP 发送 'application/soap+xml' SOAP 请求

标签 soap asp-classic msxml domdocument xmlhttprequest

如有任何帮助,我们将不胜感激;我已经研究了几天了。

下面是我目前得到的代码;不幸的是,当我运行它时出现 HTTP 415 错误; 无法处理消息,因为内容类型为“text/xml; charset=UTF-8' 不是预期的类型 'application/soap+xml; charset=utf-8'

我必须发送 application/soap+xml 的内容类型,因为这是 Web 服务允许的唯一类型;我必须在经典 ASP 中完成。

我尝试将“发送”行更改为“objRequest.send objXMLDoc.XML”,但这会给我一个HTTP 400 Bad Request错误。


strXmlToSend = "<some valid xml>"
webserviceurl = "http://webservice.com"
webserviceSOAPActionNameSpace = "avalidnamespace"

Set objRequest = Server.createobject("MSXML2.XMLHTTP.3.0")
objRequest.open "POST", webserviceurl, False

objRequest.setRequestHeader "Content-Type", "application/soap+xml"
objRequest.setRequestHeader "CharSet", "utf-8"
objRequest.setRequestHeader "action", webserviceSOAPActionNameSpace & "GetEstimate"
objRequest.setRequestHeader "SOAPAction", webserviceSOAPActionNameSpace & "GetEstimate"

Set objXMLDoc = Server.createobject("MSXML2.DOMDocument.3.0")
objXMLDoc.loadXml strXmlToSend
objRequest.send objXMLDoc
set objXMLDoc = nothing

最佳答案

这是我过去成功使用的方法:

    Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP.6.0")
    xmlhttp.open "POST", url, false
    xmlhttp.setRequestHeader "Content-Type", "text/xml; charset=utf-8" 
    xmlhttp.setRequestHeader "SOAPAction", "http://www.mydomain.com/myaction" 
    xmlhttp.send postdata
    xml = xmlhttp.responseText

关于soap - 使用经典 ASP 发送 'application/soap+xml' SOAP 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2020211/

相关文章:

java - 使用 java 对 WebService 的 SOAP 请求

java - 手动验证 XML 签名

web-services - 是否有模拟 Web 服务(REST 和 SOAP)进行测试的工具?

arrays - 使用 ASP Classic 和 aspJSON 获取嵌套的 json 值

unicode - 在经典 ASP 中过滤编码的 XSS

javascript - 引用未声明的命名空间前缀 : 'soap' when parsing MSXML soap response using selectSingleNode

c# - 如何将类似结构的 php 数组传递给 soap 客户端?

asp-classic - 经典 ASP TLS 1.2 问题

c++ - IXSLTemplate::putref_stylesheet 返回 E_INVALIDARG

delphi - MSXML XPath 可以选择属性吗? (更新: real issue was with default no-prefix namespace )