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

Sample Chapters
Commonly Asked Message Board Questions
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Stump the SQL Guru!
XML Info
Author an Article
ASP ASP.NET ASP FAQs Message Board Feedback
Print this page.
Published: Wednesday, July 04, 2001

Creating Web Services with ASP

By Ramesh Balaji and Scott Mitchell

  • Read Part 1

  • In Part 1 we looked at how to create a Web service using VisualBasic 6.0 and the SOAP Toolkit 2.0. In this part we'll examine the files created by the SOAP Toolkit wizard. In the third and final part we'll look at how to create a Web service client - a component that can access the Web service created in Part 1.

    - continued -

    Understanding WSDL and WSML
    Recall that the SOAP Toolkit wizard creates three files for us: an ASP page, a .WSDL file and a .wsml file. Take a moment to examine the .WSDL and .wsml files. Note that they contain a lot of XML. The information contained within this XML is very important and vital for the Web service to execute properly, so let's take a moment to examine both of these files.

    WSDL stands for Web Services Description Language. This file identifies the services provided by the server and the set of operations or functionalities within each service that the server supports. A WSDL file is like a contract between the server (the Web service) and the client (the program that is calling the Web service).

    A client who wishes to send a SOAP request to the Web service first obtains a copy of this WSDL file from the server. The client then uses the information in this file to format a SOAP request, which it then sends to the Web service The Web service executes the requested operation and sends the results back to the client as a SOAP response. Here are a few important sections of the WSDL file generated by SOAP Toolkit.

      <message name="AddServer.Add">
      	<part name="NumberOne" type="xsd:int" /> 
      	<part name="NumberTwo" type="xsd:int" /> 
      <message name="AddServer.AddResponse">
      	<part name="Result" type="xsd:double" /> 
      <portType name="AddServerSoapPort">
     	<operation name="Add" parameterOrder="NumberOne NumberTwo">
      		<input message="wsdlns:AddServer.Add" /> 
      		<output message="wsdlns:AddServer.AddResponse" /> 
     <service name="AddServer">
    	<port name="AddServerSoapPort" binding="wsdlns:AddServerSoapBinding">
      	<soap:address location="http://localhost/AddServer.ASP" /> 

    The service element identifies the listener, that ASP page (or ISAPI DLL) to call to invoke the Web service. Note that the service element also contains information for the port to use. The port Element identifies the operations and functionalities provided by each service. A service can have one or more ports.

    Every port element has an input and output message child element. The input message identifies the request to be sent from the client to the Web service and output message identifies the response to be sent from the Web service back to the client.

    The message elements identify each message name and data type. The message name is nothing but the parameter name in your COM class and type identifies the data type of the parameter.

    Now that we've examined the WSDL file and its purpose, let's turn our attention to the WSML. The .wsml file, an XML-formatted file, maps the operation of a service provided by the WSDL file to a specific method in the COM object.

    <servicemapping name="AddServer">
     <service name="AddServer">
         <using PROGID="prjAddServer.AddServer" cachable="0" ID="AddServerObject" /> 
     <port name="AddServerSoapPort">
      <operation name="Add">
       <execute uses="AddServerObject" method="Add" dispID="1610809344">
      	<parameter callIndex="1" name="NumberOne" elementName="NumberOne" /> 
      	<parameter callIndex="2" name="NumberTwo" elementName="NumberTwo" /> 
      	<parameter callIndex="-1" name="retval" elementName="Result" /> 

    The servicemapping element identifies the service element for which mapping is being specified. This is the service element that was created in the WSDL file. The PROGID attribute identifies the COM class, which implements all the various methods.

    The execute child element specifies the object that executes the specified operation. This element has three attributes, uses, method, and dispID, which identify the object name, the method name, and the dispatch ID of the method, respectively.

    The port element specifies the portType element as defined in the WSDL file. For each operation in a given portType element, there is one operation element in the WSML file The parameter child element of the execute element describes any method parameters. The callIndex attribute provides the parameter number, say 1 for parameter1, 2 for parameter2 and so on. A callIndex value of -1 identifies the parameter as the return parameter.

    Now that we've examined the files created by the SOAP Toolkit wizard when creating a Web service, let's turn our attention to the final task at hand - creating a component to consume a Web service. Once we've completed this, we'll be able to consume remote Web services via an ASP page!

  • Read Part 3!

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