When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles
Related Web Technologies
User Tips!
Coding Tips

Sample Chapters
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Stump the SQL Guru!
XML Info
Author an Article
Print this page.
Published: Wednesday, July 04, 2001

Creating Web Services with ASP

By Ramesh Balaji and Scott Mitchell

Web Services in Classic ASP and in ASP.NET
One of the neatest features of ASP.NET is the ease with which developers can create and expose Web services. There are plenty of articles that examine how to create Web services in ASP.NET - this article looks at how to create an consume Web services using classic ASP. For more information on using Web services with ASP.NET be sure to read:

In its current state, the Internet is used primarily for email and Web surfing. However, as the number of Web sites and on-line users grow, Microsoft (and a number of other companies, such as Sun, IBM, etc.) are seeing a need for Web services. Microsoft explains Web services and their role in the ASP.NET QuickStarts as: "The Internet is quickly evolving from today's Web sites that just deliver user interface pages to browsers to a next generation of programmable Web sites that directly link organizations, applications, services, and devices with one another. These programmable Web sites become more than passively accessed sites - they become reusable, intelligent Web Services."

This article is not intended to educate its readers on what, exactly, a Web service is, or the technical details of how a Web service works. To learn more about these topics, be sure to check out the following articles:

What this article does intend to cover is how to create a Web service server using Visual Basic 6 and the SOAP Toolkit and how to create a Web service client (a COM object able to access a Web service) and how to have this Web service client used through an ASP page.

Building our Web Service
To build a Web service using Visual Basic 6.0, we will need to do two things:

  1. Create a VB COM component
  2. Use the SOAP Toolkit 2.0 Wizard to create the needed ASP pages and WSDL to allow for a remote client to invoke and use the Web service

For this article we will build a simple VB COM component that exposes only a single method, Add, which takes two numeric parameters, adds them, and returns the result. Specifically, the function's code will be:

Public Function Add(ByVal NumberOne As long, _
                    ByVal NumberTwo As long) As Double
    Add = NumberOne + NumberTwo
End Function

Very simple. Before compiling the project into a DLL, be sure to name the project prjAddServer and the class AddServer. (To learn more about building COM objects in VB6 be sure to read: Writing a COM Object with VisualBasic 6.0.)

SOAP Toolkit Wizard Once we have the VB COM component created, all that remains for creating the Web service is to use the SOAP Toolkit Wizard. Before you can do this, though, you must download the SOAP Toolkit 2.0, a free download from Microsoft. Once you've downloaded and installed this program, you need to run the Wizard; to do this, go to Start/Programs/Microsoft SOAP Toolkit/WSDL Generator. A screenshot of this wizard can be seen to the right.

Let's step through each screen of this wizard. First, you will be asked for the name you'd like to use for the Web service as well as the location of the COM component you'd like to use. For this example, use the Web service name AddServer; in the Local path textbox enter the location of the prjAddServer.dll DLL created by VisualBasic when you built the project.

Select which methods you'd like to make available via a Web service call. On the next screen you will be asked what methods you wish to make accessible via a Web service call. Since we only have a single method (Add), make it accessible by checking the method name. Note the screenshot of this stage of the wizard on the left.

On the next screen, you will be prompted for information on the listener. The listener is a process, which is going to listen to the incoming client requests for the Web service, and is responsible for calling the appropriate COM components and returning the results back to the client. In this screen, specify the URL (I used http://localhost/ for this example, but you should probably create a separate directory and use http://www.yourserver.com) and specify that we want the listener to be an ASP page (not an ISAPI DLL). Also, go ahead and leave the XSD Schema Namespace as 2001.

Finally, we need to specify the character set to be used by the Web service, which can be UTF 8.O, or UTF 16.0. If you want to support Unicode usage, select UTF-16, else use UTF-8. Lastly, you need to specify the directory to place the .asp, .WSDL and .wsml files. You should specify a Web-accessible directory here, such as C:\Inetpub\wwwroot\, or whatever physical path maps to your Web site.

Now that we've created our Web service, anyone can access it if they know it exists. Of course, creating a component to access a Web service requires some special syntax, which we'll examine in Part 2. Before we do that, though, we'll take a look at the files created by the SOAP Toolkit wizard and what purpose they serve.

  • Read Part 2!

  • ASP.NET [1.x] [2.0] | ASPFAQs.com | Advertise | Feedback | Author an Article