Monday, July 7, 2008

02 - Deploying & Publishing Web Services


In this post we’ll learn

· Tasks need to perform when we Deploy And Publish an XML Web service.

· Learn about the XML Web services Discovery Mechanism and how to configure discovery information about your XML Web service.

Deploy & Publish XML Web Services:

Once an XML Web service is created, need is to Deploy the XML Web service to a Web server.

Deployment is the process of copying all of the service's required files on the Web Server. Deployment requires that you create a virtual root (vroot) on the Web server and copy the .asmx/.ashx files and other configuration files into that vroot. A \bin subdirectory within the new vroot houses all of the assembly dependencies.

Once deployed, the service is Published on the Web and becomes accessible to client applications.

The directory of a simple Web Service that resides in the Service vroot would be structured like the following directory:

  \Service  (vroot)

Deploying an XML Web Service

We can deploy an XML Web service on a Web server in two ways.

· You can either create a Web setup project or

· Copy the XML Web service files to the Web server.

o Either copy the complete folder or

o Copy copy the .asmx, Web.config, and Global.asax files to the application folder and the .dll file to the \bin folder

Once copied make the folder a Virtual Folder in Web Server.

After we configure your Web service application, our Web service is ready to be used by client applications. We can then right-click the .asmx file in the right pane of Internet Services Manager and select Browse from the shortcut menu to view the contents of our Web service.

Items Published with a Web Service

When we deploy an XML Web service, the following components of the Web service are published on the Web:

· The Web application directory. This component is the root directory for your XML Web service. All the XML Web service files are present in this directory or the subdirectories that you may create. You need to configure the Web application directory as an IIS Web application.

· The <WebService>.asmx file. This file is the base URL for the clients who access your XML Web service.

· The <WebService>.disco file. This is an optional file that describes the discovery mechanism for your XML Web service.


· The Web.config file. This file is optional. You include it to override the default configuration settings of your XML Web service. You can use the configuration file to customize the system or store configuration information for your application.

· The \Bin directory. This directory contains binary files for the XML Web service. If you do not define your XML Web service class in the same file as the .asmx file, the assembly containing the class should be present in the \Bin directory.

After we deploy XML Web services to a Web server, applications can locate the XML Web services by using a discovery mechanism.

Deploying an XML Web Service without DISCO

When we create a Web Service, there is no .DISCO or .WSDL files are created (only the .asmx is created). Hence these files are not present on the Web Server where Web Service is deployed. i.e Web Service is

published without .DISCO file.

These files can be automatically generated by browsing (Client Side) the .asmx using .DISCO & .WSDL switches respectively.

* http://localhost:1678/TrialService/Service.asmx?DISCO &

* http://localhost:1678/TrialService/Service.asmx?WSDL

These two files are automatically generated and placed at cleint side, when we access the WebService using ‘Add Web Reference’ approach.

Figure 1

Deploying an XML Web Service with DISCO

To deploy & publish a Web Service using DISCO, you simply need to create a .disco file and place it in the vroot along with the other service-related configuration files, like so:

  \Service  (vroot)

To create and add a .disco file, do as –

- Type in Browser http://localhost:1678/TrialService/Service.asmx?DISCO

- Then copy the content in a file with extension .disco

- If you need you can add more stuff into it.

- Place it at the level of .asmx file

Now once the DISCO is in place we can use it also for discovering. There are two utilities which provides support for discovering using .disco file.

- Add Web Reference

- Command line utility called disco.exe.

Add Web Reference & DISCO -

When you choose ‘Add Web Reference’, you can select the .disco file. Doing this will give you a new kind of screen (See Right figure).

In the Right Figure –

* Selecting ‘View Service’ shows WSDL data (http://localhost:1678/TrialService/Service.asmx?wsdl)

* Selecting ‘View Documenation’ shows data equivalent to http://localhost:1678/TrialService/Service.asmx

You can select either of the one and select ‘Add Reference’ to do the rest of the work.

Figure 2

Figure 3

Note – When we select either of the one and select ‘Add Reference’, notice that this time only the .wsdl file is added under .discomap.


This is used when we do not have access to ‘Add Web Reference’ facility. Below are the steps required to add reference using DISCO.EXE utility.

- Run with the url passed.

c:\temp> disco.exe http://localhost/math/math.disco

- This generates an output file (math.discomap) that contains information about the Web Services discovered at the specified.

- Now use wsdl.exe that can generate Web Service proxies from WSDL documents or the .discomap files generated by disco.exe. You can run it like so:

c:> wsdl.exe /l:cs math.discomap

- This generates an output file – math.cs (Proxy Class)

- Comiple it and place it under /bin

Before we end let me tell you the fact - DISCO is a Microsoft technology and introduced in .Net , for publishing and discovering Web Services.

Hope this helps.

Thanks & Regards,

Arun Manglick || Senior Tech Lead

No comments:

Post a Comment