VB6如何向Webservice发送xml?

CPlusMan 2007-10-31 07:29:54
我已经安装了SOAP包,在VB中可以引用。现在需要将一xml发送到已知地址的webservice,如何实现?

以前没做过这个,望达人指点。简单几行代码最好了,谢谢!
...全文
199 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
samzheng99 2009-02-09
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 winehero 的回复:]
首先工程引用MSXML库。将你的XML加上SOAP Envelope等,使用ServerXMLHTTP40的Send就行了。大致如下:

dim strXMLString As String '你的XML字串
dim strWebserviceURL as String 'WEBServic的URL

......

strSOAPMsg = " <?xml version='1.0' encoding='utf-8'?>"
strSOAPMsg = strSOAPMsg & " <env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/' "
strSOA…
[/Quote]

GOOD
winehero 2007-11-12
  • 打赏
  • 举报
回复
首先工程引用MSXML库。将你的XML加上SOAP Envelope等,使用ServerXMLHTTP40的Send就行了。大致如下:

dim strXMLString As String '你的XML字串
dim strWebserviceURL as String 'WEBServic的URL

......

strSOAPMsg = "<?xml version='1.0' encoding='utf-8'?>"
strSOAPMsg = strSOAPMsg & "<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/' "
strSOAPMsg = strSOAPMsg & "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' "
strSOAPMsg = strSOAPMsg & "xmlns:soapenc = 'http://schemas.xmlsoap.org/soap/encoding/' "
strSOAPMsg = strSOAPMsg & "xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"
strSOAPMsg = strSOAPMsg & "<env:Body env:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>"
strSOAPMsg = strSOAPMsg & "<m:writeErrorInfo xmlns:m='http://webService.northking.net'>"
strSOAPMsg = strSOAPMsg & "<string xsi:type='xsd:string'>" & strXMLString & "</string>"
strSOAPMsg = strSOAPMsg & "</m:writeErrorInfo>"
strSOAPMsg = strSOAPMsg & "</env:Body>"
strSOAPMsg = strSOAPMsg & "</env:Envelope>"

With oXMLHttp
.open "POST", strWebserviceURL, False
.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
.setRequestHeader "Content-Length", Len(strSOAPMsg)
.setRequestHeader "SOAPAction", "writeErrorInfo" '"hk/GetBeta3"
.send strSOAPMsg
While .readyState <> 4
Wend
Debug.Print .responseText
End With
CPlusMan 2007-11-01
  • 打赏
  • 举报
回复
多谢楼上大虾答复,我现在问题是已知XML文件内容及WebService,如何将XML发送到WebService,如:

dim strXML as string, strWebServiceURL as string

strWebServiceURL="http://128.96.191.32/webapp/DataGetherService"
strXML="<?xml version="1.0" encoding="GBK"?>" & ....

现在是如何将strXML发送到WEBService上?第一次使用,不知道怎么处理,多谢!
supergreenbean 2007-11-01
  • 打赏
  • 举报
回复
obj.MSSoapInit "http://localhost/MyService.asmx?wsdl"
ret = obj.MyMethod()
supergreenbean 2007-11-01
  • 打赏
  • 举报
回复
dim obj as new SoapClient
obj.MSSoapInit "http://128.96.191.32/webapp/DataGetherService"
ret = obj.你的方法()
CPlusMan 2007-10-31
  • 打赏
  • 举报
回复
有人帮忙吗?多谢了。。。

1,502

社区成员

发帖
与我相关
我的任务
社区描述
VB 网络编程
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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