Release and deployment (2)
Configuration selection of XML Web Services created with ASP. NET
The configuration of XML Web Services follows the same paradigm as that used by all ASP. NET Web applications. ASP. NET configuration is an XML-based text file configuration structure, which is powerful and scalable. The configuration file is just a set of XML elements that describe the configuration options for specific technical features of Microsoft. NET Framework. For XML Web Services, the configuration selection is encapsulated in the webServices XML element of the configuration file.
Configure the message transfer protocol and service help page
Used to configure the XML Web Service Message Transfer Protocol and service help page in the <protocols> XML element under the <webServices> element of the configuration file. Add the <add> and <remove> elements to make the configuration effective. The <add> element explicitly adds support for settings within the configuration file range, while the <remove> element removes support for higher configuration levels. For example, you can use Machine. the <add> element in the config file adds a protocol setting at the machine level, and then uses the Web. the <remove> element in the config file removes settings for a Web application. The following are the syntax of the <add> and <remove> elements:
<{Add | remove} name = "protocol name"/> |
The name attributes of <add> and <remove> elements have the following options:
Set |
Description |
HttpSoap |
Supports SOAP Control for XML Web Services. By default, this support is added to the installation. |
HttpGet |
Supports HTTP-GET controls for XML Web Services. This feature is not added to the installation by default. |
HttpPost |
Supports HTTP-POST controls for XML Web Services, regardless of the origin of the request. This feature is not added to the installation by default. |
HttpPostLocalhost |
When the request comes from a local computer, the HTTP-POST control for the XML Web Service is supported. If HttpPost is added to the current configuration, this setting is invalid. By default, this support is added to the installation. |
Documentation |
Specify whether a service help page is displayed. By default, this support is added to the installation. |
Note:. NET Framework 1.0 supports settings available at the HttpSoap, HttpGet, HttpPost, and Documentation levels and all default machine levels.
Security suggestions
Before using the HTTP-GET or HTTP-POST protocol for XML Web Services, you should know that doing so may expose it to unintentional calls. For example, an unexpected user may receive an email with an XML Web Service link, click the link, and use the parameters provided in the email to call the XML Web Service. You should consider whether this unintentional call is harmful before using HTTP-GET or HTTP-POST protocols.
Make the HTTP-GET and HTTP-POST protocol invalid for the whole machine
Open the Machine. config file using the text editing program you are used. (The default location of the Machine. config file is in the Config subdirectory of the installation directory .)
If the webServices section has support for HTTP-GET and HTTP-POST, comment out the lines. After doing so, the webServices section should be as follows:
<WebServices> <Protocols> <Add name = "HttpSoap"/> <! -- <Add name = "HttpPost"/> --> <! -- <Add name = "HttpGet"/> --> <Add name = "Documentation"/> <Add name = "HttpPostLocalhost"/> </Protocols> </WebServices> |
Save Machine. config.
The configuration change takes effect the next time you request the XML Web Service on this machine.
Protocol Support for separate Web applications is invalid
Use the edited program you are used to open Web. config under the root directory of the Web application. (If no Web. config file exists, create a new one .)
Modify the webServices section of Web. config to explicitly remove the protocol settings. The following example explicitly removes the HTTP-POST and HTTP-GET protocols:
<WebServices> <Protocols> <Remove name = "HttpPost"/> <Remove name = "HttpGet"/> </Protocols> </WebServices> |
Save Web. config.
The configuration change takes effect the next time you request the XML Web Service of the Web application.
Service Help Page
In a Web browser, you can navigate to the XML Web Service URL without using any parameters to view the service help page of the XML Web Service. If this service is configured. By default, the service help page contains the methods for communicating with XML Web Services and basic information about XML Web Service methods. Because the service help page is just an ASP. NET Web form, it can be replaced or modified to include 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 only used to display XML Web Services within the scope of the configuration file of the Documentation Protocol specified by the <protocols> XML element. By default, Documentation is specified in the Machine. config file.
Make the service help page invalid for a separate Web application.
Use the edited program you are used to open Web. config under the root directory of the Web application. (If no Web. config file exists, create a new one .)
Modify the webServices section of Web. config to explicitly remove the Documentation protocol.
<WebServices> <Protocols> <Remove name = "Documentation"/> </Protocols> </WebServices> |
Save Web. config.
The configuration change takes effect the next time you request the XML Web Service of the Web application.
You must cancel the Documentation protocol and disable the generation of WSDL files used for XML Web Services in any Web application. This prevents the client from generating proxy classes unless you create a custom WSDL file to set them. In order to retain the generated WSDL file for the XML Web Service in the Web application, without providing any readable information about the XML Web Service, then you can add a <wsdlHelpGenerator> element to the Web application. in the config file, set the href attribute to a blank HTML page created for you. The following code example is an excerpt from a web.configfile. You can set the service help page to the myblank.htm file.
<WebServices> <WsdlHelpGenerator HREF = "docs/MyBlank. asp"/> </WebServices> |