日期:2014-05-16  浏览次数:20950 次

asp 提交xml问题
SoapRequest="<?xml version=""1.0"" encoding=""utf-8""?>"
SoapRequest=SoapRequest&"<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"">"
SoapRequest=SoapRequest&"<soap12:Body>"
SoapRequest=SoapRequest&"<YH_Login xmlns=""http://www.jdd365.com/"">"
SoapRequest=SoapRequest&"<sToken>string</sToken>"
SoapRequest=SoapRequest&"<sTokenKey>string</sTokenKey>"
SoapRequest=SoapRequest&"<sUser>string</sUser>"
SoapRequest=SoapRequest&"<sPsw>string</sPsw>"
SoapRequest=SoapRequest&"</YH_Login>"
SoapRequest=SoapRequest&"</soap12:Body>"
SoapRequest=SoapRequest&"</soap12:Envelope>"
'response.Write(SoapRequest)
url = "http://www.jdd365.com/webservice/jd.asmx?WSDL"  '原地址
Set xmlhttp = server.CreateObject("Msxml2.XMLHTTP")
xmlhttp.Open "get",url,false
xmlhttp.Send("1.xml")

If xmlhttp.Status = 200 Then 
Set xmlDOC = server.CreateObject("MSXML.DOMDocument")
If xmlDOC.ReadyState>2 Then
Response.Write("文档已经就绪。状态:"& xmlDOC.ReadyState&"<br>" )
xmlDOC.load(xmlhttp.responseXML) 
response.write xmlDOC.childNodes(0).text&"<br>"
   response.write xmlDOC.getElementsByTagName("Result").item(0).text&"<br>"
'response.write xmlDOC.getElementsByTagName("Msg").item(0).text&"<br>"
Else
Response.Write("文档还未就绪。状态:"& xmlDOC.ReadyState )
end if
Set xmlDOC = nothing 
Else 
Response.Write xmlhttp.Status&"<br>"
Response.Write xmlhttp.StatusText
End if
Set xmlhttp = Nothing

代码如上,服务器应该返回
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><YH_LoginResponse xmlns="http://www.jdd365.com/"><YH_LoginResult><Result>0</Result><Msg>验证Key不正确</Msg></YH_LoginResult></YH_LoginResponse></soap:Body></soap:Envelope>

但是取Msg死都取不到,我已经崩溃了,求各位大神指教。通过调试软件测试,服务器能正确返回值
把提交的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><YH_Login xmlns="http://www.jdd365.com/"><sToken>string</sToken><sTokenKey>string</sTokenKey><sUser>string</sUser><sPsw>string</sPsw></YH_Login></soap12:Body></soap12:Envelope>

------解决方案--------------------
再一个版本。

<%
'Class: MoWS_JD
'ServicesName: JD
'Url: http://www.jdd365.com/webservice/jd.asmx
'Created By: MoWs

Class MoWS_JD
Public Url,Charset,targetNamespace,retXml,retBody,Method
Private Sub Class_Initialize()
Url = "http://www.jdd365.com/webservice/jd.asmx"
targetNamespace = "http://www.jdd365.com/"
Method = "Soap"
Charset="UTF-8"
End Sub

'In: sToken:string,sTokenKey:st