|
Deploying XML Web Services
Deploying a Web Service is enabling a Web service to execute on a specific Web server.
Before deploying a Web service the first thing you need to do is change the namespace
of the Web service and make sure it specifies a unique namespace. The reason
why you need to change the namespace is to avoid conflicts with other Web services.
The default Web service namespace is set to "http://tempuri.org" and there exists
a possibility that others might be using the same namespace. The namespace
you specify is used within the WSDL document of the Web service to uniquely identify
the callable entry points of the service. It is recommended that you specify
a namespace URI that you own or have under you control. Using your domain name
as part of Web service namespace gurantee uniqueness. ASP .NET Web services support
a Namespace property as part of the WebService attribute
which is set to tempuri.org by default. The following code sample shows how to set
a namespace to a Web service.
Imports System
Imports System.Web.Services
<WebService(Namespace := "http://startvbdotnet.com/namespaces/") /> _
Public Class Service1 Inherits System.Web.Services.WebService
Implementing Code
End Class
|
Deploying Web services
In general, deploying a Web service is copying the Web service entry point file (ASMX
file), the Web service assembly and related assemblies and other support files like
Web.config, etc, to the target Web server. Some Web services may just require
you to copy the ASMX file on to the target Web server. The tools you can use
to deploy a Web service are: VS .NET Web Setup Project and VS
.NET Project Copy.
VS .NET Web Setup Project
If you build your Web services with Visual Studio .NET then you can use the Web Setup
Project wizard to deploy your Web service. The Web Setup project creates a MSI file
that when executed, creates and configures a virtual directory on the Web server,
copies all the required files to execute the Web service and registers any additional
assemblies needed by the Web service. The image below displays the new project dialogue
with Web Setup as the selection.
The steps required to deploy a Web service using the Web Setup project are as follows:
1. Create the Web Setup project using the Web Setup Project template in VS .NET.
2. Build the project.
3. Copy the installation package to the target Web server
4. Run the installation package on the Web server.
When you use Web Setup Project to deploy your Web services you have an option
to specify an alternate virtual directory during the setup process and also the setup
process creates a new virtual directory and configures the virtual directory for the
Web service.
VS .NET Project Copy
VS .NET project copy is another method for deploying Web services. This
is a simple process for deployment but it does not perform the tasks like configuring
a virtual directory and file registrations that the Web service may require. You can
view the Project Copy dialogue by selecting Project->Copy Project from
main menu. Tha image below displays that.
As you can see from the above image, you have three options while using this method.
They are:
Only files needed to run this application: Copies all DLLs
with references in the bin folder as well as any files marked with a BuildAction of
Content.
All project files: Copies all project files created and
managed by VS .NET.
All files in the source project folder: Copies all VS .NET
project files as well as other files that reside in the project folders.
|