Xem mẫu

Chapter 13 The response entry clearly shows us what was returned to the client: true true 1996-07-16T00:00:00.0000000+01:00 Vins et alcools Chevalier 59 rue de l`Abbaye Reims 51100 France Again, I`ve highlighted the important parts in gray. This XML will be used to populate our ShippingDetailsResultobject on the client. One thing to watch when using proxyTrace is that, if you send another request, another entry might not appear in the list on the left. Whenever a request is made, the connection remains open for a short time. (This makes communication more efficient.) If you don`t see the new request, but connected is shown in the Status column, you`ll have to select another request in the list and then reselect the original one. Unfortunately, you can`t just click on the blank area of the list to select nothing and then flip back again so, if you only have one request, close and restart proxyTrace. How It Works proxyTrace acts as a proxy server, intercepting and examining requests for web resources before forwarding them on to the server. Most proxy servers let you examine the data that they handle and that, of course, is the sole purpose of proxyTrace. It is useful for situations when you`re getting errors from a Web Service as you can determine whether or not the service is returning the expected response. If the Web Service does appear to be working properly, you know that the problem must lie in the client-side code. In my experience, I`ve found the tool extremely useful for capturing errors returned from the Web Service. .NET doesn`t properly trap SOAP Fault messages from some Web Service implementations, and comes up with some fairly cryptic messages, like this one: 42 Web Services If you get an error similar to this when calling a web method, crack out proxyTrace and look at the response packet. You might find something like this: SOAP-ENV:Client Client Error lcTk##SBA-CSOAPBusinessArea-SOAP ERR: Schema for that business area and process are missing 57126 If you get an error like this and can`t figure out how to fix it, try contacting the Web Service owner for advice. Directory Services Although it`s likely that, in time, you`ll want to build your own Web Services, there are a growing selection of Web Services supplied by third-party sources for us to use. The question remains, however, of how to find these Web Services once companies have made them available. In the next two sections, we`ll take a look at how to use two kinds of directory services to find Web Services, namely UDDI and brokerages. UDDI UDDI, for Universal Description, Discovery, and Integration, is a type of directory geared towards business process integration. They are mainly used if you are looking for a business partner that provides some specific task, and who publishes a Web Service for that task. 43 Chapter 13 The UDDI initiative was jointly launched by Microsoft, IBM, and Ariba in May 2001. Although all three organizations were to maintain sites that would allow searching and administration of a single directory, after a little over a month Ariba announced that Microsoft and IBM would be responsible for managing the directory. It`s also expected that by the time this book is published, Hewlett-Packard will have another site. All of these sites synchronize their data so that it won`t matter which of the two or more sites are used to query UDDI. The ultimate goal of UDDI is to bring business partners together. Once they`ve done this, the companies can either interact in the usual way, that is through e-mails and phone calls, or they can use the directory to obtain the WSDL documents that describe the Web Service that each offers. Let`s take a look now at how a book distributor looking for potential new publishers might go about it. We`ll also see how that publisher could find the Web Service that will allows orders to be placed automatically. Although we`re going to look at the case of a Web Service for distributors to place orders, the service doesn`t really exist. This is a hypothetical scenario for demonstration purposes. Remember, the WSDL document is all you need to consume a Web Service, by following the same steps we took for the NorthwindWebService service. Try It Out – Finding a Business Partner with UDDI 1. Microsoft and IBM each manage two directories. One is a live site that provides working business information and the other is a test site for testing how UDDI actually works. I`ve registered a sample set of services on the Microsoft UDDI test site. Open a web browser and go to http://test.uddi.microsoft.com/. 2. To find a business partner, you must either know their name, or know something about their business. In this hypothetical case, we`re looking for book publishers. Standard Industry Classifications (SIC) codes can do this and, as long as you know the SIC code, tools on the site can find everyone in the specified category. Luckily, I happen to know that book publishing comes under Manufacturing | Printing and Publishing | Books and that the code we want is 2730. Click the Advanced Search link on the UDDI page, and enter the following: 3. Click the arrow button next to the drop down to bring up a list of businesses: 44 Web Services 4. Click on Wrox Press. This will bring up the company listing. Half way down the page you`ll find an entry marked Services. This is a list of the services that the company offers. These aren`t limited to Web Services, and can include traditional services offered by the company: 5. Click BookBuyer. This will bring up a list of bindings, which are particular to Web Services, and you`ll find a single binding on this page that points to a WSDL file: 6. Right-click on the URL of the WSDL file to bring up the context menu, and select Copy Shortcut. 7. Open Visual Studio .NET and select New Visual Basic project | Windows Application. Call it BookBuyer. The name doesn`t matter too much because we`ll throw it away after having used it to demonstrate the principles here. 8. Right-click on the BookBuyer project in Solution Explorer and select Add Web Reference. 9. Right-click the URL box at the top and select Paste. Click the green arrow. This will download the WSDL file from the Wrox site ready for use: 45 Chapter 13 As the Web Service described by the WSDL file doesn`t in reality exist, we`ll stop our discussion here. Hopefully, though, you now understand how UDDI works. We use the tools supplied to find a business partner in the directory and, ultimately, a URL (a "binding") for their Web Service. Had this been a real, existing Web Service, we`d just need to click the Add Reference button to get Visual Studio .NET to create the classes that consume the service. With those new classes in place, we could then start using the service straight away. Web Service Brokerages With UDDI, we saw an example of a Web Service directory that can help us find commercial business partners that expose Web Services as part of their line of business. This is just half the market. Over the coming months, we can expect to see companies deploy Web Services that add useful functionality to our applications. This is, after all, the central premise of Web Services – "software as services". Microsoft`s push into this area was initially dubbed Hailstorm, but is now known as ".NET My Services". This describes a set of common, fundamental services that web sites and desktop applications are likely to want to use. My Services will include the "Passport" concept and other central Internet-based services such as a diary, a file storage facility, and so on. At the time of writing, however, My Services is still very much hype, so we`re not going to dwell on it here. Another way to sift through the hundreds of Web Services coming on to the market is through a Web Service brokerage, such as Salcentral (http://www.salcentral.com/) or Grand Central (http://www.grandcentral.com/). 46 ... - slideshare.vn
nguon tai.lieu . vn