2013-01-11 49 views
0

伙计们我知道如何发布数据到web服务,但我不知道如何发布xml数据到基于soap的web服务在vb.net.Also如果你能告诉我如何接受基于xml的将受到强烈赞赏的网络服务响应。在此先感谢将数据发布到web服务基于soap

+0

你想进行序列化和反序列化自己呢? .Net框架本身负责这些操作。 – Karamafrooz

+0

可以显示我的任何一段代码或例子 – mubashir9082

回答

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"