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

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
TABLE OF CONTENTS:
  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
SEARCH DEVARTICLES

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 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


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>" & _
"</soap:envelope>"

'Write the return envelope
Response.Write strTmp
%>

blog comments powered by Disqus
ASP ARTICLES

- 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 
Support 

Developer Shed Affiliates

 




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