我正在尝试包装一个较新的.net ASMX Web服务,以便旧的经典asp应用程序可以使用它。为此,我找到了一些代码来发送soap请求。然而,在我的测试中,我的参数似乎都没有到达服务器。
服务器测试代码
<WebMethod()> _
Public Function Ping1(str As String)
If str <> "" Then
Return str
Else
Return "False"
End If
End Function
正在发送的xml:
<?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>
<Ping1 xmlns="http://tempuri.org">
<str>asdf</str>
</Ping1>
</soap12:Body>
</soap12:Envelope>
页面不断返回"False",但据我所知,这应该是发送参数的正确格式。如有任何帮助,我们将不胜感激。
正如在另一个问题中所展示的,在使用服务时应该设置正确的头:
oXmlHTTP.setRequestHeader "Content-Type", "application/soap+xml; charset=utf-8"
oXmlHTTP.setRequestHeader "SOAPAction", "http://ourNameSpace/Ping1"
请注意,不能使用tempuri.org
命名空间,还必须设置自己的命名空间。