asp tutorials, asp.net tutorials, sample code, and Microsoft news from 15Seconds
Data Access  |   Troubleshooting  |   Security  |   Performance  |   ADSI  |   Upload  |   Email  |   Control Building  |   Component Building  |   Forms  |   XML  |   Web Services  |   ASP.NET  |   .NET Features  |   .NET 2.0  |   App Development  |   App Architecture  |   IIS  |   Wireless
 
Pioneering Active Server
 Power Search





Active News
15 Seconds Weekly Newsletter
• Complete Coverage
• Site Updates
• Upcoming Features

More Free Newsletters
Reference
News
Articles
Archive
Writers
Code Samples
Components
Tools
FAQ
Feedback
Books
Links
DL Archives
Community
Messageboard
List Servers
Mailing List
WebHosts
Consultants
Tech Jobs
15 Seconds
Home
Site Map
Press
Legal
Privacy Policy
internet.commerce














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

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

HardwareCentral
Compare products, prices, and stores at Hardware Central!

An Introduction to the SOAP Toolkit - Part 2
By Robert Chartier
Rating: 3.7 out of 5
Rate this article


  • email this article to a colleague
  • suggest an article

    Introduction

    This is the second part of a two-part series geared to get you quickly started with Web services and the Microsoft SOAP Toolkit. It will allow you to consume the server that we created in the first part (see http://www.15seconds.com/issue/010725.htm) of this article. Part I shows you how to use the toolkit on the server, and deploy your Web service.

    Section 2: The Client -- Consuming the Service

     

    Step 1 -- Sample Client Source Cleanup

    As with the server, we will begin our work by looking at the samples in the MicrosoftSimple Object Access Protocol (SOAP) Toolkit. Since we used the "Calc" sample for the server section in Part I, let's copy the same client to our working directory and jump right into the code (C:\Program Files\MSSOAP\Samples\Calc\Client\SrSz\Vb\). Again, let's clean up the source files. We need to rename and delete unwanted source files.

    CalcCliSrSzVb.exe  delete
    CalcCliSrSzVb.vbp rename to CCClient.vbp
    CalcCliSrSzVb.vbw delete
    Default.htm delete
    

    Step 2 -- Getting the Client Form Ready for Use

    This time you should have no problems loading up the Visual Basic project. Once it is fully loaded, rename the project and change the caption on the form to "CCClient" and redesign the form around to look like the following:


    Figure 1.1 - A screenshot of the layout for the CCClient form.

    Notice that we added a drop-down combo box. This will store our values for the credit card type. Let's add them into the form load event. We also left the Add button on the form, but changed its name to "cmdCheck." You can download this project at anytime at http://15seconds.com/files/010808.zip.

    
    Private Sub Form_Load()
        cboCCType.Clear
        cboCCType.AddItem "V"
        cboCCType.AddItem "M"
        cboCCType.AddItem "A"
        cboCCType.AddItem "C"
        cboCCType.AddItem "D"
        cboCCType.AddItem "E"
        cboCCType.AddItem "J"
        cboCCType.ListIndex = 0
    End Sub
    
    

    Step 3 -- Getting the Client Ready to Access the Server

    There are a couple of other things in the client program that need to be changed in order to successfully connect to our server. First, ensure that the base SOAP action URI is correct. This URI is pretty simple to create. With the Microsoft toolkit, it always uses http://tempuri.org/action/CLASS_NAME where CLASS_NAME is the name of the class that you exposed in the object from Part I of this article. In this case it is AUTH.

    BASE_SOAP_ACTION_URI is correct. Change this to:

    Private Const BASE_SOAP_ACTION_URI = "http://tempuri.org/action/auth."


    Figure 1.2 - A screenshot of the Microsoft SOAP Toolkit.

    We will also need to add the location of the end point URL -- the ASP document -- which the toolkit created for you. It will be located in the directory where you chose to save the toolkit-generated files.

    Private Const END_POINT_URL =
    "http://localhost/webservices/public/ccauth/ccauth.ASP"

    Remove all of these methods:

    
    Private Sub cmdSubtract_Click()  deletePrivate Sub cmdMultiply_Click() delete
    Private Sub cmdDivide_Click() deletePrivate Sub cmdAdd_Click() delete
    
    
    We add in the method call for the cmdCheck_Click event:
    
    Private Sub cmdCheck_Click()
        txtEquals = "Authorizing..."
        DoEvents
        Execute "CheckCC"
    End Sub
    
    
    This calls the method "Execute," and we will need to change the section where it loads the parameters:
    
        Serializer.startElement "A"
        Serializer.writeString txtA.Text
        Serializer.endElement
        Serializer.startElement "B"
        Serializer.writeString txtB.Text
    
    
    Let's change it so it reads as follows:
    
        Serializer.startElement "ccnumber"
        Serializer.writeString txtA.Text
        Serializer.endElement
        Serializer.startElement "cctype"
        Serializer.writeString cboCCType.Text
    
    
    And finally, we have to change the reference to the end point URL in this method:

    Connector.Property("EndPointURL") = cbEndPoint.Text

    To

    Connector.Property("EndPointURL") = END_POINT_URL

    We now have a full client that should be working.

    Step 4 -- Testing Our Client

    Remember that if your copy of the client doesn't work, you can just download our version, and test with it instead. Hit F5 to start the Visual Basic (VB) application. Put your test value for a credit card number in the A: text box, and then choose the type and hit "Check." My test values are:

    First Test:
    A: 4510000000000000
    B: V
    Result: Wrong checksum.
    
    Second Test:
    A: 4519019173778305
    B: V
    Result: Card is OK!
    
    According to our algorithm, which is defined in our server, the second credit card number is valid. It meets the requirements that the algorithm has imposed upon it. This does not have anything to do with actual transaction information. This number might not even be a credit card. For example, if I enter the details for my Interac Bank Card, which is not a credit card, it accepts it as being a credit card because it passes the algorithm.

    Conclusion: The Client -- Consuming the Service

    This article has shown you a very quick an easy way to setup a simple Web Services client to consume the Web Service which we created in the previous article. I hope this two-part article helps you in getting your Web Service online, and fast.

    More Information

    There are among the many resources on the Internet for Web services that you could bookmarks.

    The SOAP specification:
    Simple Object Access Protocol (SOAP) 1.1 - W3C Note 08 May 2000
    http://www.w3.org/TR/SOAP/

    Microsoft SOAP:
    SOAP Toolkit 2.0 SP2 - Download
    http://msdn.microsoft.com/downloads/default.asp?URL=/code/sample.asp?url=/MSDN-FILES/027/001/580/msdncompositedoc.xml

    IBM SOAP:
    Web Services Toolkit
    http://www.alphaworks.ibm.com/tech/webservicestoolkit

    Develop.com (Don Box):
    Don Box - The Drive to 2005 and Beyond
    http://www.develop.com/dbox/

    Developer Links:
    Excellent resource for more SOAP-related links
    http://www.aspfree.com/devlinks/search.asp?catid=72

    Santra.com:
    A Web service monitoring and alerting company providing services to help you with your deployment and ongoing maintenance.
    http://www.santra.com

    About the Author

    Robert Chartier has worked in the information technologies field for more than 7 years. While studying at college he began his career working as a software and hardware technician at the college, supporting a user base of thousands of students and hundreds of instructors. Once his college days were finished he moved on to full-time studies at a university in the lower mainland of British Columbia, and landed a full-time job developing large projects for distribution on many platforms, mediums, and languages.

    Next, he moved onto Stockgroup, where he was able to tap into the Internet development market on a larger and more focused scale. In his spare time he began writing and producing content for developer-specific sites focusing on Microsoft technologies (ASP, COM/COM+, etc.). He has also been a part of many open forums on cutting-edge technologies such as the .NET Framework, Web services (SOAP), and has been invited to speak at large developer conferences and contribute to many technical publications.

    His next step was to take a position with a large B2B training marketplace, Thinq.com. At Thinq he developed many tools, including a very comprehensive search engine with custom business rules for weighting, sorting, and analysis (COM+). This led him into strong development with beta versions of Commerce Server 2000 and BizTalk Server 2000.

    His next opportunity included a large Internet development effort using technologies such as JSP (Java Beans, J2EE), Oracle, WebLogic, etc.

    Robert Chartier can be reached at rob@aspfree.com.

  • Rate This Article
    Not HelpfulMost Helpful
    1 2 3 4 5
    Supporting Products/Tools
    Stonebroom.ASP2XML
    Stonebroom.ASP2XML(c) is an interface component designed to make building applications that transport data in XML format much easier. It can be used to automatically pass updates back to the original data source.
    [Top]
    Other Articles
    Sep 22, 2005 - Implementing Remote Calling Without Using AJAX
    Right now the latest buzzword around town is AJAX. AJAX is an acronym for Asynchronous JavaScript and XML and is a method used to implement remote calling. The problem is that AJAX is only implemented in ASP.NET 2.0. This article will show you one way to implement remote calling without using AJAX or the XMLHttpRequest object. The technique outlined can even be used from classic ASP and is sufficient for most remote calling needs.
    [Read This Article]  [Top]
    Aug 18, 2005 - SQL Server 2005 XQuery and XML-DML - Part 3
    This article is the third and final installment of Alex Homer's series covering the new XML support in Microsoft SQL Server 2005. In it he covers updating the contents of xml columns, comparing traditional XML update techniques with XQuery, and using XQuery in a managed code stored procedure.
    [Read This Article]  [Top]
    Aug 11, 2005 - SQL Server 2005 XQuery and XML-DML - Part 2
    In the second part of his series on SQL Server 2005's new XML support, Alex Homer looks at extracting data from XML columns, comparing traditional XML data access approaches with XQuery, and combining XQuery and XSL-T.
    [Read This Article]  [Top]
    Aug 3, 2005 - SQL Server 2005 XQuery and XML-DML - Part 1
    Microsoft SQL Server 2005 now offers great support for and close integration with XML as a data persistence format. In the first article of his series examining this new support, Alex Homer offers an overview of how SQL Server 2005 stores XML documents and schemas, examines how it supports querying and manipulating XML documents, and provides a simple test application that allows you to experiment with XQuery.
    [Read This Article]  [Top]
    Jun 30, 2005 - Reading and Writing XML in .NET Version 2.0 - Part 3, Cont'd
    In the final article of his series on reading and writing XML in .NET 2.0, Alex Homer looks at how the updated XML document store objects XmlDocument, XmlDataDocument and PathDocument can be used to read, persist and write XML documents and fragments more easily and more efficiently than in .NET 1.x.
    [Read This Article]  [Top]
    Jun 29, 2005 - Reading and Writing XML in .NET Version 2.0 - Part 3
    In the final article of his series on reading and writing XML in .NET 2.0, Alex Homer looks at how the updated XML document store objects XmlDocument, XmlDataDocument and PathDocument can be used to read, persist and write XML documents and fragments more easily and more efficiently than in .NET 1.x.
    [Read This Article]  [Top]
    Jun 16, 2005 - Reading and Writing XML in .NET Version 2.0 - Part 2, Cont'd
    Alex Homer continues his series on reading and writing XML in .NET 2.0. In part one, we focused on the reading side of things, examining the XmlReader and XmlReaderSettings classes. In this article, we move on to look at the XmlWriter and XmlWriterSettings classes, and how they can be used to write XML documents and fragments more easily and more efficiently than in version 1.x of .NET.
    [Read This Article]  [Top]
    Jun 15, 2005 - Reading and Writing XML in .NET Version 2.0 - Part 2
    Alex Homer continues his series on reading and writing XML in .NET 2.0. In part one, we focused on the reading side of things, examining the XmlReader and XmlReaderSettings classes. In this article, we move on to look at the XmlWriter and XmlWriterSettings classes, and how they can be used to write XML documents and fragments more easily and more efficiently than in version 1.x of .NET.
    [Read This Article]  [Top]
    Jun 2, 2005 - Reading and Writing XML in .NET Version 2.0 - Part 1, Cont'd
    In the first part of his series on reading and writing XML in .NET 2.0, Alex Homer discusses the XmlReader and XmlReaderSettings classes. The XmlReader exposes several useful new features and the all new XmlReaderSettings class makes it easy to generate single or multiple instances of an XmlReader with a range of useful properties.
    [Read This Article]  [Top]
    Jun 1, 2005 - Reading and Writing XML in .NET Version 2.0 - Part 1
    In the first part of his series on reading and writing XML in .NET 2.0, Alex Homer discusses the XmlReader and XmlReaderSettings classes. The XmlReader exposes several useful new features and the all new XmlReaderSettings class makes it easy to generate single or multiple instances of an XmlReader with a range of useful properties.
    [Read This Article]  [Top]
    Mailing List
    Want to receive email when the next article is published? Just Click Here to sign up.

    Support the Active Server Industry



    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