When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles [1.x] [2.0]
ASPFAQs.com
Message Board
Related Web Technologies
User Tips!
Coding Tips
Search

Sections:
Book Reviews
Sample Chapters
Commonly Asked Message Board Questions
Headlines from ASPWire.com
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Security
Stump the SQL Guru!
Web Hosts
XML Info
Information:
Advertise
Feedback
Author an Article
Technology Jobs

















internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers
ASP ASP.NET ASP FAQs Message Board Feedback ASP Jobs
Print this page.

Windows Systems Administrator
Jupitermedia
US-CT-Darien

Justtechjobs.com Post A Job | Post A Resume

Published: Monday, July 03, 2000

SOAP: Platform-Independent Server Communication
By Erick Stover


You know the scenario, you need to somehow get data from your server to your customer's server and this needs to be implemented tomorrow. No problem, let's write a VB Com object that will create a constant link to the customer's server through Port 1452 and anytime our database is updated it will transmit the data across! No, wait. There's no way I can implement that by tomorrow. Plus, opening that port on our firewall will completely invalidate our network security guidelines. Ok, We can just send them weekly backups! Yeah, right.

- continued -

Well, what do I have left? The answer was like a shining ray of light from the heaven's above: SOAP! SOAP, the Simple Object Access Protocol, is the newest toy to come from the World Wide Web Consortium and Microsoft. Based on XML, it allows the transfer of data through the HTTP headers. This means you can conduct all you transfers on port 80, therefore preventing the opening of any security holes on your server.

How is it done? Simple. In its basic form, SOAP consists of two files: Client and Server, and its dependant on the XMLDOM and XMLHTTP objects. Lets build a client, shall we?

You want to start off by setting up your objects.

<%
  set xmldom = server.CreateObject("Microsoft.XMLDOM")
  set xmlhttp = server.CreateObject("Microsoft.XMLHTTP")

(I think it should be noted that the objects will only exists on your server if IE5 has been installed. Talk to your sysadmin if you're not sure.)

I use a constant to tell it where the SOAP server is located.

const SoapServer = "http://www.yourserver.com/SOAP/server.asp"

I then create a function that will build the request XML. You can pretty much put this anyway you like. In this case, I have a "password" and a question.

function SoapTest()
  SoapTest = SoapTest & "<SOAP:Envelope  " & _
         "xmlns:SOAP=""urn:schemas-xmlsoap-org:soap.v1"">"
  SoapTest = SoapTest & "<SOAP:Body>"
  SoapTest = SoapTest & "<TestRequest>"
  SoapTest = SoapTest & "<auth>HotGnibGnabs</auth>"
  SoapTest = SoapTest & "<message>What's the word?</message>"
  SoapTest = SoapTest & "</TestRequest>"
  SoapTest = SoapTest & "</SOAP:Body>"
  SoapTest = SoapTest & "</SOAP:Envelope>"	
end function	

Keep in mind that when making your SOAP XML, there are some required fields. Without the <SOAP:Envelope> and the <SOAP:Body>, this might work, but it just isn't SOAP. Keep that in mind. It should also be noted that the regular XML rules apply here. The tags are case sensitive and attributes have to be surrounded in quotes. (To learn more about XML be sure to check out the XML Section on 4Guys!)

In order to make use of the SOAP, you also need to have certain lines in your header. I use the XMLHTTP object to set those up.

xmlhttp.open "POST", SoapServer, false
xmlhttp.setRequestHeader "Man", POST & " " & SoapServer & " HTTP/1.1"
xmlhttp.setRequestHeader "MessageType", "CALL"
xmlhttp.setRequestHeader "Content-Type", "text/xml"
xmlhttp.send(SoapTest)

The first line tells the object that you want to open a POST connection to the SOAP server mentioned above and that I don't want it to return immediately (the default value for this is true). On the second line. I am just setting up a basic POST header. The third line lets the server know that this page is expecting info to be returned. The forth line is obvious and very required. Finally, we tell it to send the request XML.

The SOAP server (specified by the SoapServer constant) returns an XML-formatted response when it is called. Therefore, our client must have code ready to handle this response. Start with an if then statement.

'Anything other than 200 means error.
if xmlhttp.Status = 200 then
  'collects the data returned.
  Set xmldom = xmlhttp.responseXML
  
  'writes it to the screen.
  Response.write(xmldom.xml)

'Just some error checking. I use this to see why its messing up. 
Else
  Response.Write("Didn't Work
") 'Writes the error code returned by the server. Response.Write("status="&xmlhttp.status) 'Writes the accompanying text. Response.write("
"&xmlhttp.statusText) Response.Write("
"&Request.ServerVariables("ALL_HTTP")) End if

Finally, do a little cleaning.

set xmlhttp = nothing
set xmldom = nothing
%>

You now have a basic SOAP client! Now the fun part: The Server (insert scary music here...)! In Part 2 we'll look at building the server. This server will be responsible for responding to requests from SOAP clients.

  • Read Part 2


    Windows Internet Technology | ASP.NET [1.x] [2.0] | ASPMessageboard.com | ASPFAQs.com | Advertise | Feedback | Author an Article



  • JupiterOnlineMedia

    internet.comearthweb.comDevx.commediabistro.comGraphics.com

    Search:

    Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

    Jupitermedia Corporate Info


    Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

    Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

    Solutions
    Whitepapers and eBooks
    Microsoft Article: Will Hyper-V Make VMware This Decade's Netscape?
    Microsoft Article: 7.0, Microsoft's Lucky Version?
    Microsoft Article: Hyper-V--The Killer Feature in Windows Server 2008
    Avaya Article: How to Feed Data into the Avaya Event Processor
    Microsoft Article: Install What You Need with Windows Server 2008
    HP eBook: Putting the Green into IT
    Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
    Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
    Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
    Avaya Article: Setting Up a SIP A/S Development Environment
    IBM Article: How Cool Is Your Data Center?
    Microsoft Article: Managing Virtual Machines with Microsoft System Center
    HP eBook: Storage Networking , Part 1
    Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
    MORE WHITEPAPERS, EBOOKS, AND ARTICLES
    Webcasts
    Intel Video: Are Multi-core Processors Here to Stay?
    On-Demand Webcast: Five Virtualization Trends to Watch
    HP Video: Page Cost Calculator
    Intel Video: APIs for Parallel Programming
    HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
    Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
    MORE WEBCASTS, PODCASTS, AND VIDEOS
    Downloads and eKits
    Sun Download: Solaris 8 Migration Assistant
    Sybase Download: SQL Anywhere Developer Edition
    Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
    Red Gate Download: SQL Compare Pro 6
    Iron Speed Designer Application Generator
    MORE DOWNLOADS, EKITS, AND FREE TRIALS
    Tutorials and Demos
    How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
    eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
    IBM Article: Collaborating in the High-Performance Workplace
    HP Demo: StorageWorks EVA4400
    Intel Featured Algorhythm: Intel Threading Building Blocks--The Pipeline Class
    Microsoft How-to Article: Get Going with Silverlight and Windows Live
    MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES