Home arrow ASP arrow Page 3 - 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 - The Server
(Page 3 of 5 )

Our server needs to be configured to accept the HTTP post sent by the client. It will be noted that we direct the client's post to a URL on our local server http://localhost/soap.asp. So our first job is to create this page, to listen for, and process, SOAP calls to our server. We know that our ASP will receive an XML document, in the form of an HTTP post, with a method name (GetSalesTax), and a parameter (SalesTotal). So, to write our basic listener service, all we need do is deconstruct the body of the request (the SOAP envelope) and pull out the value of the SalesTotal parameter.

The SOAP envelope posted by the client is contained in the body of the request, or in ASP terms the Request object; and because it is XML, we can load it into an instance of Microsoft's XMLDOM in our ASP. Soap.asp begins like this:

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


Thus objReq contains the SOAP envelope we created on the client, and we can extract the value of the SalesTotal parameter by running an XSL pattern query, using the SelectSingleNode method of the XML DOM object:

strQuery = "SOAP:Envelope/SOAP:Body/m:GetSalesTax/SalesTotal" varSalesTotal = objReq.SelectSingleNode(strQuery).Text

With the parameter extracted, we can make our calculation to get the sales-tax:

varSalesTax = varSalesTotal * 0.04

Now we have the return value for sales-tax the response - ready to pass back to the client, but as with the request, we need to format this response correctly, in order to comply with the SOAP standard. The SOAP response envelope conforms to a format-type identical to the request. The only difference is that the "IN" parameter (SalesTotal, in our case) is replaced by an "OUT" parameter SalesTax, and the method name indicates that the document is a response:

<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>4</SalesTax>
</m:GetSalesTaxResponse>
</SOAP:Body>
</SOAP:Envelope>


We can build up this document, either by string-concatenation, or by creating a new instance of a DOM, and appending the appropriate nodes.

Back on the client, the response is received, and can be decoded by extracting the appropriate node from the Envelope document:

Dim objReturn As New MSXML.DomDocument
objReturn.LoadXML strReturn
strQuery = _
"SOAP:Envelope/SOAP:Body/m:GetSalesTaxResponse/SalesTax"
dblTax = objReturn.SelectSingleNode(strQuery).Text


And that's it! A functional, compliant SOAP service in a few easy steps. Of course, the service that we have provided is far from sophisticated, but that is to miss the point. In the not-too-distant future, Visual Studio 7 will completely mask the implementation of SOAP; but I believe that there is value in understanding the way the engine turns beneath the hood. SOAP itself is a very simple protocol; and I hope you leave this article with a better understanding the infrastructure that lies behind SOAP, and the methodology through which SOAP-based component services are going to be provided in the future.
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