home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 40 / IOPROG_40.ISO / SOFT / NETFrameworkSDK.exe / comsdk.cab / samples.exe / QuickStart / aspplus / doc / webservicesintro.aspx < prev    next >
Encoding:
Text File  |  2000-06-11  |  4.7 KB  |  67 lines

  1.  
  2. <!-- #include virtual="/quickstart/aspplus/include/header.inc" -->
  3.  
  4. <h4>Introducing Web Services</h4>
  5.  
  6. <P>
  7. The Internet is quickly evolving from today's Web sites that just deliver UI Pages to browsers to a next generation of programmable Web sites that directly link organizations, applications, services, and devices with one another.  These programmable Web sites become more than passively accessed sites - they become reusable, intelligent Web Services.
  8. </P>
  9. <P>
  10. The NGWS runtime provides built-in support for creating and exposing Web Services û using a programming abstraction that is consistent and familiar to both ASP+ Web Forms developers and existing VB users.  The resulting model is both scalable and extensible û and embraces open Internet standards (HTTP, XML, SOAP, SDL) so that it can be accessed and consumed from any client or Internet enabled device.
  11. </P>
  12. <H5>ASP+ Web Services</H5>
  13. <P>
  14. ASP+ provides support for Web Services with the .asmx file. An .asmx file is a text file that is similar
  15. to an .aspx file. These files can be part of an ASP+ application that includes .aspx files. These files are then URI-addressable, just as .aspx are.
  16. </P>
  17. <P>
  18. The following is a very simple example of an .asmx file:
  19. </P>
  20.  
  21. <div class="code"><pre>
  22. <%@ WebService Language=öC#ö %>
  23.  
  24. using System.Web.Services;
  25.  
  26. public class HelloWorld : WebService {
  27.  
  28.      [ WebMethod ]
  29.      public String SayHelloWorld() {
  30.           return "Hello World";
  31.      }
  32. }
  33. </pre></div>
  34.  
  35. <P>
  36. This file starts with an ASP+ directive <I>WebService</I>, and sets the language to C# (you could also set the language to VB or C). Next, it imports the namespace System.Web.Services. This namespace is needed and you must include it. Next, the class <B>HelloWorld</B> is declared. This class is derived from the base class <B>WebService</B>. Finally, any methods that will be accessible as part of the service have the custom attribute <B>[WebMethod]</B> (or <"WebMethod>" in Visual Basic) in front of their signatures.
  37. </P>
  38. <P>
  39. To make this service available, we might name the file HelloWorld.asmx and place it on a server called <B>Foo</B> inside a virtual directory called <B>Bar</B>. With Internet Explorer 5, you could then enter the URL <B>http://foo/bar/HelloWorld.asmx</B> and the resulting page would show the public methods for this Web Service (those marked with the WebMethod attribute), as well which protocols (such as SOAP, or HTTP GET) you can use to invoke these methods. Entering <B>http://foo/bar/HelloWorld.asmx?SDL</B> into the Internet Explorer address location produces the same information as an XML file, based on the Service Description Language (SDL) grammar. This SDL file is very important, and is used by clients that will access the service.
  40. </P>
  41. <H5>Accessing Web Services</H5>
  42. <P>
  43. Besides technology that allows developers to create Web Services, NGWS provides a sophisticated set of tools and code to consume, or access as a client, Web Services. Because Web Services are based on open protocols such as the Simple Object Access Protocol (SOAP) and HTTP, this client technology can also be used to consume non-ASP+ Web Services. Of course, the level of integration between ASP+ Web Services and the client technology is extremely high.
  44. </P>
  45. <P>
  46. With the SDK, there is a tool called WebServiceUtil.exe. This program can be used to download the SDL description of a Web Service, and create a proxy class that addresses this service. For example, you could enter: 
  47.  
  48. <div class="code"><pre>
  49. WebServiceUtil /c:proxy /pa:http://someDomain.com/someFolder/HelloWorld.asmx?SDL
  50. </pre></div>
  51.  
  52. A Proxy class called HelloWorld.cs would then be created. 
  53. </P>
  54. <P>This class would look very similar to the class created in the previous section. It would contain a method called <B>SayHelloWorld</B> that returns a String. Compiling this proxy class into an application, and then calling this proxy classes method results in the proxy class packaging a SOAP request across HTTP, and take the SOAP-encoded response, and marshall it as a string.
  55. </P>
  56. <P>From the client perspective, the code would be simple:
  57.  
  58. <div class="code"><pre>
  59. HelloWorld myHelloWorld = new HelloWorld();
  60. String return = myHelloWorld.SayHelloWorld();
  61. </pre></div>
  62.  
  63. And the return would be "Hello World".
  64. </p>
  65. <P>
  66. The rest of this section deals with more advanced topics with Web Services, such as sending and receiving complex datatypes. There is also a section on Text Pattern Matching, which is an exciting technology to address <i>any</I> URI that returns text as if it was a Web Service. You can also perform data binding operations with Web Services, and that is discussed in the Data section.
  67. <!-- #include virtual="/quickstart/aspplus/include/footer.inc" -->