The following document describes the process for creating an SOAP/XMLP web service with Visual C#. During the course of this
walkthrough, you will accomplish the following activities:
To complete the walkthrough, you must provide the following:
For this guide, you will create a simple
web service application that implements the methods described in the following
web service description (WSDL):
To create an ASP.NET Web Service application
On the File menu, choose New Project.
In the New Project dialog box, select the ASP.NET Web Service
Application icon (you may need to ensure
that .NET framwork 3.5 is selected in the drop down menu at the
top of the dialog box) .
Name the project IIS.
Click OK to create the project.
In Code Window, change
the value of the
to reflect the desired domain name for your web service. For example:
In Solution Explorer, rename the service from Service1
Inspect the code that has been generated in the Code Window.
You should have a class that contains a public
WebMethod called HelloWorld.
You will now generate stubs for the web service methods using the WSDL file and
Visual Studio's wsdl command line tool.
We will use the
WSDL provided by the Transport Layer Expert Panel
To generate web service method stubs from a WSDL file
- In your start menu, navigate to the Visual Studio folder,
expand the Visual Studio Tools folder and select the
Visual Studio .Net command prompt.
- Use the wsdl command to generate the web service method stubs:
wsdl http://openimmunizationsoftware.us:6394/ImmMessagingServer/client_Service?wsdl /language:CS /server
- /language: specifies the language to use for the generated proxy/stub class. Choose from CS, VB, JS, VJS. Default is CS (C#).
- /server: generates an abstract class for an XML web service implementation. Default is to generate client proxy classes.
You should now have a file name client_Service.cs that contans
the web service method stubs implemented in C#. If you open client_Service.cs you should see the following code
In the previous section you generated web service method stubs from a wsdl
file. The method stubs are defined in an abstract class called
client_Service, and the methods themselves are abstract. You will now
add this client_Service to your web service project and implement the web
To Implement the Web Service Methods
- Add the client_Service class to your project by dragging
the client_Service.cs file into the Solution Explorer
on the right side of the Visual Studio window.
- Edit the ImmunizationInformationSystemService so that it
implements the client_Service class. This is done by appending
the inheritance operator ( : ) after the class name followed by
the name of the class we wish to inherit. For example:
public class ImmunizationInformationSystemService :
- Implement the connectivityTest() and
sumitSingleMessage() methods inside of the
The result should look like the contents of the image below:
We can test the web service by running the application in debug mode by
navigating to the Debug menu and selecting Start
Debugging. When we do this a internet browser should open to a page
that displays the name of our web service and the list of available methods:
Clicking on the Service Description link will bring us to the
service description, which is an XML document that uses the Web Services
Description Language (WSDL). The service description describes what
services are available and how to interact with those services. Web Serivice
clients will use this WSDL to determine how to communicate with our web service.
Clicking on one of the methods listed on this page will bring us to a generic
client application that we can use to test our web service by invoking the
specified method. Let try this now by clicking on the connectivityTest method:
This page displays the portions of the wsdl that are relevant to the
connectivityTest method. We can invoke the method by filling in a value
for the echoBack textbox and clicking the Invloke button.