Asp.net|web|web Services | Creating a Deployment XML Web service involves copying the. asmx file and the assembly files used by any XML Web service, rather than taking part of the Microsoft.NET framework as a virtual directory on the Web server. For information about how to deploy an XML Web service, see Deploying XML Web Services. XML Web Services apply to users who use discovery mechanisms. Users can browse a particular discovery file or the root of a Web server to locate the discovery file. From these files, they can judge which services are useful to them.
Deploying XML Web Services
Deploying an XML Web service involves copying the. asmx file and the assembly files used by any XML Web service, rather than part of the Microsoft.NET framework, to the Web server.
For example, suppose you name an XML Web service as StockServices. To deploy an XML Web service, you need to create a virtual directory on your Web server and put an XML Web service. asmx file into this directory. This virtual directory should also be an IIS Web application, although it is not required. A typical deployment will have the following directory structure:
\inetpub \wwwroot \stockservices Stockservices.asmx \ Bin |
Your XML Web service uses a compilation that is not part of the Microsoft.NET framework.
an entry for an XML Web service publication
When you publish an XML Web service, the following entries are used to deploy a Web server.
Entry |
Describe |
Web application Directory |
As the root directory of your XML Web service. All the files are stored in this directory. This directory should be marked for use by an IIS Web application. |
. asmx file |
The base URL of the client that invoked the XML Web service. This file can be any valid file name. |
. disco files |
(optional) as a discovery mechanism for XML Web services.. disco files are not automatically created for XML Web services. This file can be any valid file name. |
Web.config file |
(optional) If you need to override the default configuration settings, you can include a Web.config file. XML Web Services Use this configuration file to allow customization and scalability of the system. For example, if your XML Web service needs to be validated in your system and other Web applications are not needed, you can provide an XML Web service-specific Web.config file. |
\ Bin Directory |
Contains a binary file for this XML Web service. If your XML Web service class and the. asmx file are not in the same directory, the part that contains the class must be in the \ Bin directory. |
an XML Web service was found
XML Web service discovery is the process of locating and inquiring about XML Web service descriptions, which is a preliminary step in accessing an XML Web service. By discovering the process, an XML Web service client can learn at design time what an XML Web service is, what it can do, and how to interact with it appropriately.
You can programmatically discover when an XML Web service publishes a. disco file,. Disco is an XML document that contains a connection to other discovery documents, XSD schemas, and service descriptions. In other words, an XML Web service created with ASP.net automatically provides the ability to generate discovery documents. When used with? Disco URL access, a discovery document is automatically generated for the XML Web service. For example, if the URL to an XML Web service is Www.contoso.com/getquote.asmx, then automatically generates a discovery document with Www.contoso.com/getquote.asmx?DISCO.
To enable the discovery of an XML Web service:
Create an XML document using your favorite editor and add the tag <?xml version= "1.0" to the first line.
In this XML document, add a <discovery> element, such as:
Within the <discovery> element, add references to service descriptions, XSD schemas, and other discovery documents.
You can add a reference to whatever you want to expose. The service description reference is specified in a discovery document by adding an <contractRef> element using the Http://schemas.xmlsoap.org/disco/scl/XML domain namespace. Similarly, references to other discovery documents and XSD schemas are specified by adding <discoveryRef> and <schemaRef> XML elements, respectively. For XSD schema references, you must specify the XML domain namespace Http://schemas.xmlsoap.org/disco/schema ... The following code example has a reference to a discovery document, a service description, and an XSD schema.
> docref= "Service.htm" xmlns= "http://schemas.xmlsoap.org/disco/scl/"/> xmlns= "http://schemas.xmlsoap.org/disco/schema/"/> |
References can be related to the directory where the document is found, as shown in the Discoveryref element, or with a URI, as shown in the Contractref element.
Deploy the discovery document to this Web server by copying the discovery document to a virtual directory on the Web server.
Optionally, if you want to allow the intended consumer to navigate to a URL by specifying an IIS application without having to specify a document, you can add a default page to the IIS application. This is beneficial to the intended consumer, who do not have to know the name of any discovery document. Users can provide URLs that you want to find in the following discovery process:
Http://MyWebServer/MyWebApplication
If the default page for a Web application is an HTML page:
Add a link to the discovery document in the
If the default page for a Web application is an XML document:
Add a link to the discovery document in the
Optionally, if you use Visual Studio.NET, you can turn on dynamic discovery to allow XML Web service client applications to discover available XML Web services on a Web server that does not create discovery documents. When dynamic discovery is turned on, the client application specifies a URL, such as Www.contoso.com/default.vsdisco, that references a file with the. vsdisco part in the Add Web Reference dialog box, instead of a specific discovery document.
To turn on dynamic discovery for a Web server, modify machine.config to add the following <add> element.
Type= "System.Web.Services.Discovery.DiscoveryRequestHandler, System.Web.Services, version=1.0.3300.0, Culture=neutral, publickeytoken=b03f5f7f11d50a3a " Validate= "false"/> |
Note: When dynamic discovery is turned on, all XML Web services and discovery documents that exist on the Web server are found. Therefore, you must be careful when you turn on dynamic discovery, because it may inadvertently expose sensitive data if the Web server is not in a secure network with firewalls.
Configuration selection for XML Web services created with ASP.net
The configuration of an XML Web service follows the same paradigm used by all asp.net Web applications. Asp. NET configuration is an xml-based text file configuration structure that is both powerful and extensible. A configuration file is simply a set of XML elements that describe the configuration choices for the specific technical features of the Microsoft.NET framework. In the case of XML Web services, the configuration selection is encapsulated in the webservices XML element of the configuration file.
Configuring the Messaging Protocol and Service help pages
The XML Web Service Messaging Protocol and Service help page is configured in the XML element under the element of the configuration file. By adding the and elements to the configuration, the setting within the scope of the configuration file is valid. The element explicitly adds support for settings within the scope of the configuration file, while the element removes support for higher configuration levels. For example, you can use the element in the Machine.config file to add a protocol setting at the machine level, and then use the element in the Web.config file to remove settings for a Web application. The following are the syntax for the and elements:
<{add|remove} name= "protocol name"/> |
The <add> and <remove> element's Name property has the following options:
Set up |
Describe |
HttpSoap |
A control that supports the SOAP protocol for XML Web services. The installation has added this support by default. |
HttpGet |
A control that supports the Http-get protocol for XML Web services. Installation By default does not add this support. |
HttpPost |
A control that supports the Http-post protocol for XML Web services, regardless of the origin of the request. Installation By default does not add this support. |
Httppostlocalhost |
A control that supports the Http-post protocol for an XML Web service when the request originates from the local computer. This setting is not valid if HttpPost is added to the current configuration. The installation has added this support by default. |
Documentation |
Specifies whether a service help page is displayed. The installation has added this support by default. |
Note: the. NET Framework version 1.0 supports HTTPSOAP, HttpGet, httppost, and documentation settings and all settings that can be used by the default machine level.
Security Recommendations
Before using the Http-get or Http-post protocol for XML Web services, you should know that doing so might expose it to unintended invocations. For example, an expected user might receive an e-mail message with an XML Web service link, click on the link, and invoke the XML Web service using the parameters provided in the email. You should consider whether this unintended invocation is harmful until you use the Http-get or Http-post protocol.
making Http-get and http-post protocols ineffective for the whole machine
Open the Machine.config file using your custom text editor. (The default location for machine.config files is in the \CONFIG subdirectory of the installation directory.) )
If you have support for Http-get and Http-post in the WebServices section, then annotate these lines. After doing so, the WebServices section should read as follows:
Save Machine.config.
The configuration changes will take effect the next time the XML Web service on this machine is requested.
failed protocol support for individual Web applications
Use your custom editing program to open the Web.config in the Web application root directory. (If there is no Web.config file, create one.) )
Modify the WebServices section of the Web.config to explicitly remove protocol settings. The following example explicitly removes the Http-post and Http-get protocols:
Save Web.config.
The configuration changes will take effect the next time the XML Web service for this Web application is requested.
Service help Page
Navigating to the URL of an XML Web service without using any parameters in a Web browser allows the customer to view the service help page for this XML Web service if the service is configured like this. The Service help page contains the basic information about the methods of communicating with XML Web services and XML Web service methods by default. Because the service help page is simply a asp.net web form, it can be replaced or modified to contain entries similar to the company logo. The file name of the service help page is specified in the <wsdlHelpGenerator> XML element of the configuration file. The Service help page is used only to display XML Web services that have the scope of the configuration file for the documentation protocol specified by the <protocols> XML element. By default, documentation is specified in the Machine.config file.
Invalidates the service help page for a separate Web application.
Use your custom editing program to open the Web.config in the Web application root directory. (If there is no Web.config file, create one.) )
Modify the WebServices section of the web.config to explicitly remove the documentation protocol.
Save Web.config.
The configuration changes will take effect the next time the XML Web service for this Web application is requested.
Note Canceling the documentation protocol also prohibits the generation of WSDL files for XML Web services within any Web application. This prevents the client from generating proxy classes unless a custom WSDL file is created to set them up. To preserve the generation of WSDL files used in the Web application for XML Web services without providing any readable information about the XML Web service, Then you can add an <wsdlHelpGenerator> element to the Web application's Web.config file and set the href attribute to create a blank HTML page for you. The following code example is an excerpt of a Web.config file that sets the service help page as a myblank.htm file.