将数据发布到基于webservice soap

时间:2013-01-11 10:55:49

标签: xml vb.net web-services

伙计我知道如何将数据发布到网络服务但我不知道如何将xml数据发布到vb.net中的基于肥皂的web服务。如果你能告诉我如何从web服务接受基于xml的响应非常感谢。提前致谢

1 个答案:

答案 0 :(得分: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"