soap 请求调用WebService1的问题
bear6 2005-03-25 04:35:38 asmx的标准SOAP示例。所显示的占位符需要由实际值替换。
POST /Service1.asmx HTTP/1.1
Host: 192.168.0.103
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/WebService1/Service1/CreateOA"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<CreateOA xmlns="http://tempuri.org/WebService1/Service1">
<username />
<pwd />
</CreateOA>
</soap:Body>
</soap:Envelope>
我构造的:
<?xml version="1.0" encoding="utf-8" ?>
- <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
- <soap:Body>
- <CreateOA xmlns="http://tempuri.org/WebService1/Service1">
<username>123</username>
<pwd>123</pwd>
</CreateOA>
</soap:Body>
</soap:Envelope>
消息头设置:
Set xmlhttp = server.CreateObject("Msxml2.XMLHTTP")
xmlhttp.Open "POST",url,false
xmlhttp.setRequestHeader "HOST","192.168.0.103"
xmlhttp.setRequestHeader "Content-Type", "text/xml;charset=utf-8"
xmlhttp.setRequestHeader "Content-Length",LEN(SoapRequest)
xmlhttp.setRequestHeader "SOAPAction", "http://tempuri.org/WebService1/Service1/CreateOA"
可我返回的xmlhttp.Status始终是500
然后得到的响应是
<?xml version="1.0"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <soap:Fault> <faultcode>soap:Server</faultcode> <faultstring>服务器无法处理请求。 --> 从类型“XmlNode()”到类型“String”的强制转换无效。</faultstring> <detail/> </soap:Fault> </soap:Body> </soap:Envelope>