伙计们,我知道如何将数据发布到 Web 服务,但我不知道如何将 xml 数据发布到 vb.net 中基于肥皂的 Web 服务。另外,如果您能告诉我如何接受来自 Web 服务的基于 xml 的响应,我们将不胜感激. 提前致谢
问问题
308 次
1 回答
1
您可以使用 XMLHttpRequest - 如下示例
Dim strEnvelope As String
Dim request As New MSXML.XMLHTTPRequest
Dim strReturn As String
Dim objReturn As New MSXML.DOMDocument
Dim strQuery As String
Private Sub btnAcct_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnResidentAcct.Click
strEnvelope = "POST /Account/Account.asmx HTTP/1.1 " & _
"Host: 1.1.1.1" & _
"Content-Type: text/xml; charset=utf-8" & _
"Content(655) : length()" & _
"SOAPAction: ""http://www.account.net/Account/Account""" & _
"<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>" & _
"<Account xmlns=""http:// www.account.net/Account "">" & _
"</Account>" & _
"</soap:Body>" & _
"</soap:Envelope>"
'Set up to post to our localhost server
request.open("post", "http:// www.account.net/Account ")
request.setRequestHeader("Content-Type", "text/xml")
request.setRequestHeader("Account", "http://www.account.net/Account/Account")
request.send(strEnvelope)
strReturn = request.responsetext
objReturn.loadXML(strReturn)
strQuery = "SOAP:Envelope/SOAP:Body/m:AccountResponse/Account"
于 2013-01-11T12:25:04.650 回答