Revisiting a Web Service s .asmx Files

Revisiting a Web Service’s .asmx Files

Each time you create a .NET web service, Visual Studio .NET generates three files that use .asmx within their file extensions. Table 12.3 briefly describes each file’s contents.

Table 12.3:  Files That Visual Studio .NET Creates That Use the .asmx Extension for Each Web Service You Create

Filename

Purpose

Service1.asmx

Contains a single-line entry that specifies the programming language used to create the web service, the name of the file that contains the statements that implement the web service (which developers refer to as the code-behind file), and the web service’s class name

Service1.asmx.vb (or .cs)

Contains the program statements that implement the operations the web service performs

Service1.asmx.resx

An XML-based file that specifies the resources the web service consumes

If you examine the simple Hello web service that you created in Chapter 2, you will find files with the names service1.asmx, service1.asmx.vb, and service1.asmx.res. As discussed, the file Service1.asmx should contain a single-line entry that specifies the programming language used to create the web service, the file that contains the web service’s statements, and the web service’s class name, as shown here:

<%@ WebService Language="vb" Codebehind="Service1.asmx.vb" _ Ä  %>

Likewise, the file Service1.asmx.vb (or .cs if you are programming in C#) in Listing 12.2 will contain the actual program statements that implement the web services. Developers refer to this file as the code-behind file.

Listing 12.2 Service1.asmx.vb

start example
<WebMethod()> Public Function DateString() As String    DateString = Now.Date.ToShortDateString End Function <WebMethod()> Public Function TimeString() As String    TimeString = Now.TimeOfDay.ToString() End Function <WebMethod()> Public Function DayOfWeek() As Integer    DayOfWeek = Now.Date.DayOfWeek End Function 
end example

Finally, Service1.asmx.resx, shown in Listing 12.3, is an XML-based file whose entries provide information about the resources the service consumes.

Listing 12.3 Service1.asmx.resx

start example
<?xml version="1.0" encoding="utf-8" ?> <root>   <xsd:schema  xmlns=""    xmlns:xsd="http://www.w3.org/2001/XMLSchema"    xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">    <xsd:element name="root" msdata:IsDataSet="true">       <xsd:complexType>         <xsd:choice maxOccurs="unbounded">            <xsd:element name="data">               <xsd:complexType>                  <xsd:sequence>                     <xsd:element name="value" type="xsd:string"                      minOccurs="0" msdata:Ordinal="1" />                       <xsd:element name="comment" type="xsd:string"                        minOccurs="0" msdata:Ordinal="2" />                  </xsd:sequence>                  <xsd:attribute name="name" type="xsd:string" />                  <xsd:attribute name="type" type="xsd:string" />                  <xsd:attribute name="mimetype" type="xsd:string" />               </xsd:complexType>             </xsd:element>           <xsd:element name="resheader">             <xsd:complexType>               <xsd:sequence>                 <xsd:element name="value" type="xsd:string"                  minOccurs="0" msdata:Ordinal="1" />               </xsd:sequence>               <xsd:attribute name="name" type="xsd:string"                use="required" />             </xsd:complexType>           </xsd:element>         </xsd:choice>       </xsd:complexType>    </xsd:element>   </xsd:schema>  <resheader name="ResMimeType">       <value>text/microsoft-resx</value>  </resheader>  <resheader name="Version">       <value>1.0.0.0</value>  </resheader>  <resheader name="Reader">       <value>System.Resources.ResXResourceReader, System.Windows.Forms,        Version=1.0.3300.0, Culture=neutral,        publicKeyToken=b77a5c561934e089</value>  </resheader>  <resheader name="Writer">       <value>System.Resources.ResXResourceWriter, System.Windows.Forms,        Version=1.0.3300.0, Culture=neutral,        PublicKeyToken=b77a5c561934e089</value>  </resheader> </root>
end example




. NET Web Services Solutions
.NET Web Services Solutions
ISBN: 0782141722
EAN: 2147483647
Year: 2005
Pages: 161
Authors: Kris Jamsa

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net