Home arrow ASP arrow Page 4 - An Introduction To XML SOAP Using ASP and VB6

An Introduction To XML SOAP Using ASP and VB6

Using ASP and VB6 but still haven't come to grips with SOAP? In this article the ComponentSource team show us how to create a request/respose system in next to no time using simple VBScript and MSXML.

Author Info:
By: ComponentSource Team
Rating: 5 stars5 stars5 stars5 stars5 stars / 85
August 12, 2002
  1. · An Introduction To XML SOAP Using ASP and VB6
  2. · Step By Step
  3. · The Server
  4. · VB Client Code
  5. · Conclusion

print this article

An Introduction To XML SOAP Using ASP and VB6 - VB Client Code
(Page 4 of 5 )

Here's the entire code for your VB client:

Sub Main()
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>" & _

'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", _

'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 = _
dblTax = objReturn.selectSingleNode(strQuery).Text

Debug.Print dblTax
End Sub

ASP Server Code
This code resides in an ASP Soap.asp, in the root directory of the web server.

Set objReq = Server.CreateObject("Microsoft.XMLDOM")

'Load the request into XML DOM
objReq.Load Request

'Query the DOM for the input parameter
strQuery = "SOAP:Envelope/SOAP:Body/m:GetSalesTax/SalesTotal"
varSalesTotal = objReq.SelectSingleNode(strQuery).Text

'Calculate the sales tax
varSalesTax = varSalesTotal * 0.04

'Prepare the return envelope
strTmp = _
"<soap:envelope xmlns:soap=""urn:schemas-xmlsoap-org:soap.v1"">" & _
"<soap:header></soap:header>" & _
"<soap:body>" & _
"<m:getsalestaxresponse xmlns:m=""urn:myserver/soap:TaxCalc"">" & _
"<salestax>" & varSalesTax & "</salestax>" & _
"</m:getsalestaxresponse>" & _
"</soap:body>" & _

'Write the return envelope
Response.Write strTmp

blog comments powered by Disqus

- Central Scoreboard with Flash and ASP
- Calorie Counter Using WAP and ASP
- Creating PGP-Encrypted E-Mails Using ASP
- Be My Guest in ASP
- Session Replacement in ASP
- Securing ASP Data Access Credentials Using t...
- The Not So Ordinary Address Book
- Adding and Displaying Data Easily via ASP an...
- Sending Email From a Form in ASP
- Adding Member Services in ASP
- Removing Unconfirmed Members
- Trapping HTTP 500.100 - Internal Server Error
- So Many Rows, So Little Time! - Case Study
- XDO: An XML Engine Class for Classic ASP
- Credit Card Fraud Prevention Using ASP and C...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials