TAILIEUCHUNG - Professional ASP.NET 1.0 Special Edition- P37

Professional Special Edition- P37:Those of us who are Microsoft developers can't help but notice that .NET has received a fair amount of visibility over the last year or so. This is quite surprising considering that for most of this period, .NET has been in its early infancy and beta versions. I can't remember any unreleased product that has caused this much interest among developers. And that's really an important point, because ignoring all the hype and press, .NET really is a product for developers, providing a great foundation for building all types of applications | Now that we ve had a foundation in UDDI and WSDL let s shift our discussion towards actually using WSDL to build a proxy class that is capable of calling a Web Service. Building Web Service Proxies A proxy does work on behalf of others. A good example is proxy web server software. Users configure their web browser to use a proxy server and make requests for Internet resources such as http to the proxy. The proxy then makes a request on the behalf of the browser to the requested URL. We can use proxy classes to represent the Web Service we want to call. In the previous chapter we created a class named Fibonacci that supports a single method called GetSeqNumber. We compiled the class into a .NET assembly and deployed it to an application s bin directory on the server . We can use this assembly as both a Web Service and a local class inside an page. For example we could write the following page using VB .NET script runat server Public Sub Page_Load sender As Object e As EventArgs Dim fibonacci As New Fibonacci 5 End Sub script Index of 5 in the Fibonacci Series is asp literal id result runat server However we ve also implemented this class as a Web Service which means that we also have the ability to call the GetSeqNumber method via SOAP over a network. The question is can we expect applications that wish to use our Fibonacci Web Service to work with the raw SOAP messages the HTTP and XML directly Probably not. Consumers of our Web Service should not have to formulate their own XML messages and then encapsulate those messages in HTTP in order to send them to the appropriate destination. The same is true for receiving messages. What consumers should use is a proxy representation of the Web Service. Fibonacci Proxy The WSDL describes the Web Service and because the WSDL is so complete we can create a proxy class using tools that are capable of reading the WSDL. For example we can build a proxy

19    14    0
182    11    0
138    4    0
3    5    0
142    10    0