Home
Links
Home Page
HTML_AJAX In operation
The guidebook on an exchange of links
Bases of creation of server elements of management. Events
Postback and Query String - to combine incompatible
Kategorial`noe ordering of results of search
We change URL'? hurriedly
XML+MSSQL+ASP.NET. A part 1.
As work Web services ASP.NET
New in ASP.NET 2. Structures of users
Transformation of a target stream of the XML-given at a conclusion in a browser means ASP.NET and XS
Expectation of performance of long process in ASP.NET
Difference between HttpModule and HttpHandler
New in asp.net 2 - subjects and skiny.
Review GridView
What is GridView
Role of a content in promotion of a site
Review DetailsView
Job with databases
AutoPostBack Binding to the data. Collections. Check of correctness of the entered data

As work Web services ASP.NET

Introduction


Today there are fundamentally various two ways of realization Web of the services based on HTTP, in Microsoft ® .NET. The first and most nizkourovnevoj technics{technical equipment} is the spelling of special class IHttpHandler which is inserted into a chain .NET HTTP pipeline. This approach demands use System. Web API for processing entering HTTP messages and System. Xml API for processing envelope SOAP which is taking place in body HTTP. At a spelling special obrabotchika also it is required to create manually document WSDL which precisely describes your realization. To make all this it is correct, the deep understanding of specifications XML, XSD, SOAP and WSDL is necessary, that is a frightening condition for the majority.


More productive way to realize Web services is use WebMethods of Microsoft shell ASP.NET. With special class IHttpHandler for .asmx (named WebServiceHandler) which provides a set of functionalities XML necessary for you, XSD, SOAP and WSDL ASP.NET is delivered. And, as WebMethods the shell protects you from the complexities underlying XML technologies, you can quickly concentrate on existing problems business of logic.


The choice between tekhnikami results realizations in the general{common} comparison of benefits and losses between flexibility and efficiency, as shown in Figure 1. Creation special IHttpHandler gives you unlimited flexibility, but also demands greater time for a spelling, testing and debugging of a code. WebMethods shell facilitates the organization of yours Web service and speed of development, but you are obviously limited to frameworks of the shell. However in cases when WebMethods shell does not provide that is necessary to you, there is an opportunity to expand her{it}, adding own additional functionalities.


In general while you have not mastered XML, XSD, SOAP and WSDL and do not want to be troubled, working with them directly, continue to work with WebMethods shell better. She delivers the basic services which are necessary for the majority final Web services, and also some interesting opportunities of expansion which allow to bring the shell into accord to your concrete needs. Proceeding from this, further in clause{article} internal mechanisms of job WebMethods are discussed. If you the newbie in XML Schema and SOAP before continuing read Understanding XML Schema

WebMethods shell


WebMethods shell is engaged in transformations SOAP of messages to methods of a class .NET. It is done{made}, first of all, by annotation of your methods by attribute [WebMethod], taking place in space of names System. Web. Services. For example, the following class .NET contains four methods, two of which are annotated by attribute [WebMethod]:



using System. Web. Services;


public class MathService

{

   [WebMethod]

   public double Add (double x, double y) {

      return x + y;

}

   [WebMethod]

   public double Subtract (double x, double y) {

      return x - y;

}

   public double Multiply (double x, double y) {

      return x * y;

}

   public double Divide (double x, double y) {

      return x / y;

}

}




To use this class with WebMethods shell, you should compile it{him} in assembly and to copy in a virtual directory of a directory bin. In this example methods Add and Subtract then can be opened as operation Web of service while with methods Multiply and Divide it to make it is impossible (since they have not been marked by attribute [WebMethod]).


You open Add and Subtract as operations Web of service through .asmx a file. To make it, create the new text file Math.asmx containing the following the simple description, and place it{him} in the same virtual directory, which contains also assembly (pay attention: the file is located in a virtual directory, instead of in its{her} affiliated directory bin):



<% WebService class = "MathService" %>




This description specifies obrabotchiku .asmx, what class to use for WebMethods, and obrabotchik in the wonderful image cares of all the rest. For example, suppose, the virtual directory is called 'math' and contains Math.asmx alongside with that, that the affiliated directory bin contains assembly, the call http://localhost/math/math.asmx results to that obrabotchik .asmx generates the page of the documentation shown in Figure 2 (see further).


It is one of the basic variants of job obrabotchika .asmx. The file .asmx usually contains only description WebService which refers to class Web of service by name (as in an example shown below). Hence, in this case, assembly should be already compiled and placed in a directory bin a virtual directory. Obrabotchik .asmx also provides JIT compilation of the initial code which is taking place in a file .asmx. For example, the following file (named Mathjit.asmx) contains description WebService together with an initial code of a class to which refers.



<% WebService class = "MathServiceJit" language = " C * " %>


using System. Web. Services;


public class MathServiceJit

{

   [WebMethod]

   public double Add (double x, double y) {

      return x + y;

}

   [WebMethod]

   public double Subtract (double x, double y) {

      return x - y;

}

   public double Multiply (double x, double y) {

      return x * y;

}

   public double Divide (double x, double y) {

      return x / y;

}

}




When to this file dostupajutsja through HTTP for the first time, obrabotchik .asmx compiles a source and correctly places assembly. Pay attention, that in description WebService should be specified also and the programming language that obrabotchik .asmx could choose in the environment of performance the correct compiler. Patent defect of this approach is that you do not know about mistakes of compilation until address to a file.


At creation of new project Web of service in Visual Studio ® .NET you always use technics{technical equipment} of " two files “ when the initial file of a class is separated from a file .asmx which refers to him{it}. The integrated environment of development (IDE) well hides it from you but if you will press Show All Files toolbars Solution Explorer, you will see in the project on two files for each class Web of service. By the way, Visual Studio .NET does not support for files .asmx syntactic allocation or IntelliSense ®, therefore you decide whether to follow in this direction. In Web projects Visual Studio .NET also cares of creation of a virtual directory and automatic compilation of assembly in a directory bin a virtual directory.


Before immersing in a detail of job obrabotchika .asmx let's shortly discuss, as messages from Internet Information Server (IIS), first of all, in obrabotchike .asmx are processed. When entering HTTP the message reaches{achieves} port 80 to define{determine}, what ISAPI DLL should be used for his{its} processing, IIS uses the information of metabase IIS. Installation .NET connects expansions .asmx with Aspnet_isapi.dll, as shown in Figure 3.



Aspnet_isapi.dll is the standard expansion ISAPI delivered .NET Framework which simply directs HTTP searches to the separate working process named Aspnet_wp.exe. Aspnet_wp.exe carries out a role of a host for the nontechnical environment of performance and .NET HTTP pipeline. As soon as the message enters in .NET HTTP pipeline, pipeline looks through in a file of a configuration, what class IHttpHandler should be used for the given expansion. If you see file Machine.config will see, that he contains httpHandler, connected with expansion .asmx, as shown here:



<configuration>

  <system.web>

    <httpHandlers> 

        <add verb = "*" path = "*.asmx " type = " System. Web. Services. Protocols. WebServiceHandlerFactory,

System. Web. Services, Version=1.0.3300.0, Culture=neutral,

PublicKeyToken=b03f5f7f11d50a3a " validate = "false"/>

...




So, when the message acts in .NET HTTP pipeline, being aimed at a file .asmx, pipeline comes into class WebServiceHandlerFactory to create new object WebServiceHandler which can be used for processing search (with the help of method IHttpHandlerProcessRequest). Then object WebServiceHandler opens a physical file .asmx to define{determine} a classname, containing yours WebMethods. More detailed information on job .NET HTTP pipeline is submitted in HTTP Pipelines: Securely Implement Request Processing, Filtering, and Content Redirection with HTTP Pipelines in ASP.NET (http: // msdn.microsoft.com/library/default.asp? url =/msdnmag/issues/02/09/HTTPPipelines/default.aspx).


Right after how .NET HTTP pipeline causes obrabotchik .asmx, wonderful image processing XML, XSD, SOAP and WSDL begins. Other functionalities given obrabotchikom .asmx, can be divided{shared} into three basic groups: 1) co-ordination of messages, 2) transformation XML to objects and 3) automatic generating WSDL and documentation. Give each of these groups we shall consider in more details.

Dispecherizacija messages


When HTTP pipeline causes obrabotchik .asmx, looking through description WebService in a file .asmx, he defines{determines}, what class .NET to use. Then he looks through acted{arrived} HTTP the message to define{determine}, which method to cause in the given class. To call operation Add shown in the previous examples, entering HTTP the message should look approximately so:



POST/math/math.asmx HTTP/1.1

Host: localhost

Content-Type: text/xml; charset=utf-8

Content-Length: length

SOAPAction: " http: // tempuri.org/Add "


<soap:Envelope

  xmlns:soap = " http: // schemas.xmlsoap.org/soap/envelope / "

>

  <soap:Body>

    <Add xmlns = " http: // tempuri.org / ">

      <x> 33 </x>

      <y> 66 </y>

    </Add>

  </soap:Body>

</soap:Envelope>




Actually in entering HTTP the message there are two sites which can be used for definition of a method which should be called in a class: heading SOAPAction or a name of a required element (i.e. a name of an element within the limits of an element soap:Body). In this case even one of them defines{determines} a name of a method which wants to call the sender.


For dispecherizacii messages obrabotchik .asmx by default uses heading SOAPAction. Means, obrabotchik .asmx looks at heading SOAPAction in the message, and then, using .NET a reflection, checks methods of a class. He considers{examines} only the methods marked with attribute [WebMethod], but, looking through value SOAPAction of each method, he precisely defines{determines}, what method to cause. As we obviously have not defined{determined} value SOAPAction in methods of our class, obrabotchik .asmx accepts, that value SOAPAction will be a combination of space of names Web of service and a name of a method. As we also have not defined{determined} also space of names, obrabotchik by default appropriates{gives} http://tempuri.org. Thus, default value SOAPAction for method Add will be http://tempuri.org/Add.


You can change space of names Web of service, marking a class attribute [WebService], as well as exact value SOAPAction, marking WebMethods attribute [SoapDocumentMethod], as shown further:



using System. Web. Services;

using System. Web. Services. Protocols;


[WebService (Namespace = " http: // example.org/math ")]

public class MathService

{

   [WebMethod]

   public double Add (double x, double y) {

      return x + y;

}

   [WebMethod]

   [SoapDocumentMethod (Action = "urn:math:subtract")]

   public double Subtract (double x, double y) {

      return x - y;

}

   ...

}




Now obrabotchik .asmx expects, that value SOAPAction for method Add will be http://example.org/math/Add and urn:math:subtract for method Subtract (as we have obviously set this value). For example, following message HTTP of search causes operation Subtract:



POST/math/math.asmx HTTP/1.1

Host: localhost

Content-Type: text/xml; charset=utf-8

Content-Length: length

SOAPAction: "urn:math:subtract"


<soap:Envelope

  xmlns:soap = " http: // schemas.xmlsoap.org/soap/envelope / "

>

  <soap:Body>

    <Subtract xmlns = " http: // example.org/math ">

      <x> 33 </x>

      <y> 66 </y>

    </Subtract>

  </soap:Body>

</soap:Envelope>




If obrabotchik .asmx does not find SOAPAction, suitable for entering HTTP the message, he simply forms an exclusive situation (we shall consider later how exclusive situations are processed). If for dispecherezacii a method you do not use heading SOAPAction, marking a class property RoutingStyle of attribute [SoapDocumentService], you can specify obrabotchiku .asmx to use a name of an element of search. If you do{make} it also it is necessary to specify, that WebMethods do not require value SOAPAction, by an establishment of their values in an empty line, is as shown lower:



using System. Web. Services;

using System. Web. Services. Protocols;


[WebService (Namespace = " http: // example.org/math ")]

[SoapDocumentService (

  RoutingStyle=SoapServiceRoutingStyle. RequestElement)]

public class MathService

{

   [WebMethod]

   [SoapDocumentMethod (Action = "")]

   public double Add (double x, double y) {

      return x + y;

}

   [WebMethod]

   [SoapDocumentMethod (Action = "")]

   public double Subtract (double x, double y) {

      return x - y;

}

    ...

}




In this case obrabotchik at all does not consider{examine} value SOAPAction - he uses instead of him{it} a name of an element of search. For example, it is expected, that the name of an element of search for method Add will be Add (from space of names http://example.org/math), as shown in this message HTTP of search:



POST/math/math.asmx HTTP/1.1

Host: localhost

Content-Type: text/xml; charset=utf-8

Content-Length: length

SOAPAction: " "


<soap:Envelope

  xmlns:soap = " http: // schemas.xmlsoap.org/soap/envelope / "

>

  <soap:Body>

    <Add xmlns = " http: // example.org/math ">

      <x> 33 </x>

      <y> 66 </y>

    </Add>

  </soap:Body>

</soap:Envelope>




The first means, that does{makes} obrabotchik .asmx at reception entering HTTP messages, - he defines{determines} how to redirect the message in corresponding WebMethod. However before he can really call a method, he should transform entering XML in .NET objects.

Transformation XML to objects


As soon as obrabotchik WebMehod has defined{determined}, what method should be called, he should deserializovat` XML the message in .NET objects which can be given during a call of a method. As well as at dispecherizacii messages, obrabotchik checks a class with the help of a reflection to find out, how to process entering XML the message. Class XmlSerializer carries out automatic transformation between XML and objects in space of names System. Xml. Serialization.


XmlSerializer makes possible transformation of any public type .NET in type XML Schema and, at the same time, can spend automatic transformations between .NET objects and documents XML (see. Figure 4). XmlSerializer it is limited to those opportunities which today supports XML Schema, therefore he cannot work with all complexities of today's objective models, such as complex not the treelike diagrams of objects duplicating indexes, etc. Despite of it, XmlSerializer can work with the majority of the complex types used by developers.


For above mentioned example Add XmlSerializer will transform elements x and y in .NET double value which then can be given by call Add. Method Add returns causing value such as double which then should be again serializovano in XML an element in frameworks SOAP of the answer.



Also XmlSerializer can automatically work with complex types (except for the restrictions described above). For example, following WebMethod calculates distance between two structures Point:



using System;

using System. Web. Services;


public class Point {

  public double x;

  public double y;

}

[WebService (Namespace = "urn:geometry")]

public class Geometry {

  [WebMethod]

  public double Distance (Point orig, Point dest) {

    return Math. Sqrt (Math. Pow (orig.x-dest.x, 2) +

                     Math. Pow (orig.y-dest.y, 2));

}

}




SOAP the message of search for this operation will contain element Distance which includes two affiliated elements, orig and dest, and each of these elements should contain affiliated x and y elements:



<soap:Envelope

  xmlns:soap = " http: // schemas.xmlsoap.org/soap/envelope / "

>

  <soap:Body>

    <Distance xmlns = "urn:geometry">

      <orig>

        <x> 0 </x>

        <y> 0 </y>

      </orig>

      <dest>

        <x> 3 </x>

        <y> 4 </y>

      </dest>

    </Distance>

  </soap:Body>

</soap:Envelope>




In this case SOAP the message of the answer will contain element DistanceResponse including element DistanceResult such as double:



<soap:Envelope

  xmlns:soap = " http: // schemas.xmlsoap.org/soap/envelope / "

>

  <soap:Body>

    <DistanceResponse

      xmlns = "urn:geometry">

      <DistanceResult> 5 </DistanceResult>

    </DistanceResponse>

  </soap:Body>

</soap:Envelope>




Used by default XML transformation uses a name of a method as a name of an element of search and names of parameters as names of affiliated elements. The structure of each parameter depends on structure of type. Names public fields and properties are simply transformed to affiliated elements, as in a case x and y (in Point). A name of an element of the answer by default becomes a name of an element of the search, terminating in a word "Response". The element of the answer also contains the affiliated elements named as well as elements of search, only terminating in a word "Result".


There is an opportunity to be released{exempted} from standard XML transformations by use of a plenty of the built - in attributes of transformation. For example, for transformation of a name of type and space of names it is possible to use attribute [XmlType]. To supervise how parameters or members of a class transform elements or attributes, you can use attributes [XmlElement] and [XmlAttribute], accordingly. And for the control over that as the method is transformed to names of elements in messages of the search / answer, it is possible to use attribute [SoapDocumentMethod]. For example, familiarize with following version Distance in which various attributes are used:



using System;

using System. Web. Services;

using System. Web. Services. Protocols;

using System. Xml. Serialization;


public class Point {

  [XmlAttribute]

  public double x;

  [XmlAttribute]

  public double y;

}

[WebService (Namespace = "urn:geometry")]

public class Geometry {

  [WebMethod]

  [SoapDocumentMethod (RequestElementName = "CalcDistance",

     ResponseElementName = "CalculatedDistance")]

  [return: XmlElement ("result")]

  public double Distance (

    [XmlElement ("o")] Point orig, [XmlElement ("d")] Point dest) {

    return Math. Sqrt (Math. Pow (orig.x-dest.x, 2) +

                     Math. Pow (orig.y-dest.y, 2));

}

}




In this version Distance it is expected, that entering SOAP the message will look as follows:



<soap:Envelope

  xmlns:soap = " http: // schemas.xmlsoap.org/soap/envelope / "

>

  <soap:Body>

    <CalcDistance xmlns = "urn:geometry">

      <o x = "0" y = "0"/>

      <d x = "3" y = "4"/>

    </CalcDistance>

  </soap:Body>

</soap:Envelope>




Also it will be generated such SOAP the message of the answer:



<soap:Envelope

  xmlns:soap = " http: // schemas.xmlsoap.org/soap/envelope / "

>

  <soap:Body>

    <CalculatedDistance xmlns = "urn:geometry">

      <result> 5 </result>

    </CalculatedDistance>

  </soap:Body>

</soap:Envelope>




For realization and definition of the above mentioned transformation used by default, obrabotchik .asmx uses a document / literal style SOAP. It means, that description WSDL will contain alphabetic definitions XML schema, describing both elements of search, and the elements of the answer used in SOAP messages (i.e. rules SOAP of coding are not used).


Obrabotchik .asmx also makes possible use a rpc/literal of style SOAP. It means, that SOAP Body contains XML performance of call RPC and parameters serializovyvajutsja with use of rules SOAP of coding (i.e. XML Schema it is not necessary). Accordingly, instead of attributes [SoapDocumentService] and [SoapDocumentMethod] you use [SoapRpcService] and [SoapRpcMethod]. In more detail about distinctions in these styles see in section MSDN Understanding SOAP (http: // msdn.microsoft.com/webservices/building/frameworkandstudio/default.aspx? pull =/library/en-us/dnsoap/html/understandsoap.asp).


As you can see, there is an opportunity to reserve process of transformation of the given method in SOAP the message. XmlSerializer provides the powerful mechanism of serialization with many opportunities about which we do not have time here to speak. In more detail how works XmlSerializer, see in section MSDN Moving to .NET and Web Services (http: // msdn.microsoft.com/library/default.asp? url =/msdnmag/issues/01/11/webserv/). I also have considered many nuances XmlSerializer which has been not opened in my monthly column MSDN Magazine, XML Files (http: // msdn.microsoft.com/msdnmag/find/default.aspx? type=Ti*phrase=XML%20Files) (look the list of columns in online archives).


Except for job on deserializacii parameters, obrabotchik .asmx also can deserializovat`/serializovat` SOAP headings. SOAP headings are processed not how parameters as they usually are considered as the untied information without direct binding to a concrete method. Therefore processing of heading is usually done{made} with the help of levels of the interception completely protecting WebMethods from necessity to deal by processing of headings.


If, all the same, you want to use the information of heading from WebMethod, you should give a class .NET, inherited from SoapHeader which represents XML Schema headings (following the recommendations of transformation above mentioned). Then you define{determine} a variable of a member of this type, carrying out role of "filler" for copies of heading. And at last, you mark everyone WebMethod, requiring in access to heading, defining{determining} a name of that field where you want it{him} to direct.


For example, SOAP the search containing heading UsernameToken with the purpose autentifikacii:



<soap:Envelope

  xmlns:soap = " http: // schemas.xmlsoap.org/soap/envelope / "

>

  <soap:Header>

    <x:UsernameToken xmlns:x = " http: // example.org/security ">

      <username> Mary </username>

      <password> yraM </password>

    </x:UsernameToken>

  </soap:Header>

  <soap:Body>

    <CalcDistance xmlns = "urn:geometry">

       ...




To make possible{probable} for obrabotchika .asmx deserializaciju heading, all over again it is necessary to define{determine} a class .NET, representing prospective type XML Schema (pay attention: if at you actually is XML Schema for heading, you can generate a class, using xsd.exe/c). In this case the corresponding class looks as follows:



[XmlType (Namespace = " http: // example.org/security ")]

[XmlRoot (Namespace = " http: // example.org/security ")]

public class UsernameToken: SoapHeader {

   public string username;

   public string password;

}




Then it is just necessary to define{determine} a variable of a member in your class WebMethod to store{keep} a copy of a class of heading, and to annotate WebMethods attribute [SoapHeader], is as shown lower:



using System;

using System. Web. Services;

using System. Web. Services. Protocols;


[WebService (Namespace = "urn:geometry")]

public class Geometry {


  public UsernameToken Token;


  [WebMethod]

  [SoapHeader ("Token")]

  public double Distance (Point orig, Point dest) {


    if (! Token.username. Equals (Reverse (Token.password)))

       throw new Exception (" access denied ");


    return Math. Sqrt (Math. Pow (orig.x-dest.x, 2) +

                     Math. Pow (orig.y-dest.y, 2));

}

}




Then in WebMethod you can address to field Token and take the information which has been given by heading. You also can send headings back to the client, using the same technics{technical equipment} - you should define{determine} a direction of heading in the description of attribute [SoapHeader]. More detailed information on processing SOAP of headings in WebMethods shell see in section MSDN Digging into SOAP Headers with the .NET Framework. (http: // msdn.microsoft.com/webservices/building/frameworkandstudio/default.aspx? pull =/library/en-us/dnservice/html/service06182002.asp)


Obrabotchik .asmx also provides automatic serialization of exclusive situations .NET. Any raw exclusive situation intercepted obrabotchikom .asmx, automatically serializuetsja in element SOAP Fault in the answer. For example, in the previous example if the login name does not coincide with the password, our code forms an exclusive situation .NET. Then obrabotchik .asmx will process her{it} and serializuet in SOAP the answer, is as shown lower:



<soap:Envelope

  xmlns:soap = " http: // schemas.xmlsoap.org/soap/envelope / "

>

  <soap:Body>

    <soap:Fault>

      <faultcode> soap:Server </faultcode>   

      <faultstring> Server was unable to process request. - *gt; access denied </faultstring>

      <detail/>

    </soap:Fault>

  </soap:Body>

</soap:Envelope>




If you want to supervise even more element SOAP Fault, you can generate obviously also object SoapException, defining{determining} all details of element SOAP Fault, such as elements faultcode, faulstring, faultactor and detail. More detailed is submitted to the information in section MSDN Using SOAP Faults (http: // msdn.microsoft.com/webservices/building/frameworkandstudio/default.aspx? pull =/library/en-us/dnservice/html/service09172002.asp).


As you can see, to understand, how works WebMethods, it is necessary to understand with the mechanism underlying serialization, and all variety of his{its} opportunities. Advantage of the mechanism of serialization is that he hides all underlying XML API a code which usually you should write in special obrabotchike. However, while the majority of developers count it the positive moment, the some people name it lack because still want to work independently with SOAP the message within the limits of realization WebMethod. In more details how to use such mixed approach, see in section MSDN Accessing Raw SOAP Messages in ASP.NET Web Services (http: // msdn.microsoft.com/library/default.asp? url =/msdnmag/issues/03/03/WebServices/default.aspx).

Automatic generating WSDL


Clients should know precisely, how should look SOAP the message successfully to work with it{him}. Standard is to give descriptions Web of service through WSDL (and built - in XSD definitions). For this purpose obrabotchik .asmx automatically generates both page of the documentation, and description WSDL which precisely reflects interface WebMethod. If you have applied group of attributes of transformation to yours WebMethods, all of them will be reflected in the generated documentation.


If you see a file .asmx will find page of the documentation, such as shown in Figure 2. This page of the documentation is generated by page .aspx, named DefaultWsdlHelpGenerator.aspx (taking place in C:windowsMicrosoft. NETFramework v1.0.3705config). If will open a file, you will see, what is it only standard page ASP.NET which uses .NET a reflection for generating the documentation. This opportunity allows the documentation to correspond{meet} to a code always. Simply modifying this file, you can change the generated documentation.


Also it is possible to block generating of the documentation on the basis of a virtual directory, defining{determining} other file of the documentation in file Web.config:



<configuration>

  <system.web>

    <webServices>

      <wsdlHelpGenerator href = "MyDocumentation.aspx"/>

    </webServices>

    ...




If the client finishes search GET for .asmx symbols "? wsdl " in a line of search, obrabotchik .asmx instead of the documentation generates description WSDL. Clients can use description WSDL for generating proxy classes, which automatically know how to communicate with Web service (i.e. using Wsdl.exe in .NET).


To change process of generating WSDL, you can write class SoapExtensionReflector and register it{him} with WebMethods shell in file Web.config. Then, when obrabotchik .asmx will generate description WSDL, he will call your class and will enable you to change the final description delivered to the client. In more detail how to write classes SoapExtensionReflector, see in section MSDN SoapExtensionReflectors in ASP.NET Web Services (http: // msdn.microsoft.com/msdntv/episode.aspx? xml=episodes/en/20030320WebServicesMP/manifest.xml).


Using two various technics, you can block process of generating WSDL completely. First, for access by clients you can give static WSDL the document in your virtual directory and then block the generator of the documentation, having removed it{him} from your file Web.config, is as shown lower:



<configuration>

  <system.web>

    <webServices>

      <protocols>

        <remove name = "Documentation"/>

      </protocols>

      ...




A little more automated technics{technical equipment} is use of attribute [WebServicesBinding] for definition of a site of static document WSDL in a virtual directory which realizes class WebMethod. You also should define{determine} name WSDL binding which realizes everyone WebMethod, using attribute [SoapDocumentMethod]. Process of automatic generating WSDL imports your static WSDL a file and "will turn" it{him} in the new description of service. More detailed information on this technics{technical equipment} is submitted in clause{article} MSDN Place XML Message Design Ahead of Schema Planning to Improve Web Service Interoperability (http: // msdn.microsoft.com/library/default.asp? url =/msdnmag/issues/02/12/WebServicesDesign/).


Today it is very hard to create manually WSDL because till now there is no enough of accessible editors WSDL. Therefore automatic generating of documentation / WSDL is a valuable part of WebMethods shell which will facilitate a life to many developers.

The conclusion


WebMethods shell ASP.NET provides the high-efficiency approach to construction Web of services. WebMethods have made possible{probable} to use traditional methods .NET as operations Web of service which support HTTP, XML, XML Schema, SOAP and WSDL. Obrabotchik WebMethod (.asmx) automatically defines{determines} how to send entering SOAP messages in a corresponding method, in what point he automatically serializuet entering XML elements in corresponding objects .NET. And simplifying a life of the client, obrabotchik .asmx also provides automatic support for generating the documentation for the person (HTML) and for the machine (WSDL).


Though in comparison with special IHttpHandlers WebMethods shell can look a little limited, she provides the powerful model of expansibility known as SOAP shell of expansion. Expansions SOAP provide an opportunity for satisfaction of your concrete needs to enter additional functionalities, besides discussed here. For example, Microsoft has issued Web Services Enhancements 1.0 for Microsoft .NET (WSE) which simply give class SoapExtension entering in WebMethods shell support for several GXA of specifications. More detailed information on spelling SOAP of expansions is submitted in MSDN Fun with SOAP Extensions (<http: // msdn.microsoft.com/webservices/building/frameworkandstudio/default.aspx? pull =/library/en-us/dnaspnet/html/asp03222001.asp>).