XML SOAP

VB Client Code

Sub Main()
  Dim objHTTP As New MSXML.XMLHTTPRequest
  Dim strEnvelope As String
  Dim strReturn As String
  Dim objReturn As New MSXML.DOMDocument
  Dim dblTax As Double
  Dim strQuery As String
 
  'Create the SOAP Envelope
  strEnvelope = _
    "<soap:envelope xmlns:soap=""urn:schemas-xmlsoap-org:soap.v1"">" & _
    "<soap:header></soap:header>" & _
    "<soap:body>" & _
    "<m:getsalestax xmlns:m=""urn:myserver/soap:TaxCalculator"">" & _
    "<salestotal>100</salestotal>" & _
    "</m:getsalestax>" & _
    "</soap:body>" & _
    "</soap:envelope>"
 
  'Set up to post to our local server
  objHTTP.open "post", "http://localhost/soap.asp", False
 
  'Set a standard SOAP/ XML header for the content-type
  objHTTP.setRequestHeader "Content-Type", "text/xml"
 
  'Set a header for the method to be called
  objHTTP.setRequestHeader "SOAPMethodName", _
    "urn:myserver/soap:TaxCalculator#GetSalesTax"
 
  'Make the SOAP call
  objHTTP.send strEnvelope
 
  'Get the return envelope
  strReturn = objHTTP.responseText
 
  'Load the return envelope into a DOM
  objReturn.loadXML strReturn
 
  'Query the return envelope
  strQuery = _
    "SOAP:Envelope/SOAP:Body/m:GetSalesTaxResponse/SalesTax"
  dblTax = objReturn.selectSingleNode(strQuery).Text
 
  Debug.Print dblTax
End Sub

You might also like...

Comments

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“It is practically impossible to teach good programming style to students that have had prior exposure to BASIC. As potential programmers, they are mentally mutilated beyond hope of regeneration.” - E. W. Dijkstra