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>
...全文
201 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
bear6 2005-03-29
  • 打赏
  • 举报
回复
没明白
Tomgus 2005-03-28
  • 打赏
  • 举报
回复
可以这样:
string content= objNodeList[0].InnerXml;
broadury 2005-03-28
  • 打赏
  • 举报
回复
应该是你的程序出现问题了。
XmlNode是不能直接转化为string的。你可以用ToString方法进行转换
baobei7758 2005-03-28
  • 打赏
  • 举报
回复
mark
jackie615 2005-03-28
  • 打赏
  • 举报
回复
up
haoco 2005-03-27
  • 打赏
  • 举报
回复
up
bear6 2005-03-25
  • 打赏
  • 举报
回复
WebService是没有问题

Set soapClient = Server.CreateObject("MSSOAP.SoapClient30")
soapClient.ClientProperty("ServerHTTPRequest") = True
soapClient.mssoapinit("http://192.168.0.103/Service1.asmx?WSDL")
sMAC = soapClient.CreateOA("bear2","1234")
response.write sMAC

这样调用是可以的

12,162

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧