2013-01-11 53 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"