Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 75 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
75
Dung lượng
7,98 MB
Nội dung
Figure 10.55 Web Services Explorer—Query Results Page Figure 10.56 Web Services Explorer—Service Details Page Iteration 6: Discovering and Publishing Web Services 499 500 CHAPTER 10 • Web Services Figure 10.57 Web Services Explorer—WSDL Service Details Page Figure 10.58 Web Services Explorer—WSDL Binding Details Page 8. The Invoke a WSDL Operation page is displayed (see Figure 10.59). This page lists the inputs for the selected operation. View the operation details. Click the Add link and enter a stock symbol. Click the Go button. Iteration 6: Discovering and Publishing Web Services 501 Figure 10.59 Web Services Explorer—Invoke a WSDL Operation Page 9. The Web Services Explorer invokes the operation and displays the result in the Status pane (see Figure 10.60). View the result of the operation in the Status pane. Double-click on the title of the Status pane to maximize it. Click the Source link to view the request and response SOAP messages. WSIL As you can see from the preceding exercise, UDDI is very complex. WSIL is a much simpler way to publish information about Web services. WSIL is an XML format that you publish on your Web site to advertise available Web services. WSIL documents can refer to WSDL, UDDI, and other WSIL documents. By convention, the root WSIL document for a Web site is named inspection.wsil. It can directly list all the Web services or point to subordinate WSIL documents. In the future, Web service crawlers might search the Web for inspection.wsil files and automatically index them in UDDI or other registries. WSIL was jointly developed by IBM and Microsoft, but Microsoft still uses the precursor DISCO format to publish Web service information. There is not a lot of WSIL deployed at present. However, XMethods supports it and several other Web service publication technologies. In this part of the iteration you will use the Web Services Explorer to view a WSIL document published at XMethods. You will also use WTP to create your own WSIL document to publish the League Planet Web services. Do the following: 1. Open a Web browser and surf to http://www.xmethods.net The XMethods home page is displayed (see Figure 10.61). Look at the Programmatic Interfaces section, which lists UDDI, WS-Inspection, DISCO, RSS, and SOAP. These are the ways that XMethods publishes Web service information. Click the Access link. 2. The Programmatic Interfaces to XMethods page is displayed (see Figure 10.62). View the many access methods supported by XMethods. Copy the WS-Inspection link, which gives the URL to the inspection.wsil document. 502 CHAPTER 10 • Web Services Figure 10.60 Services Explorer—GetQuoteResponse Figure 10.61 XMethods Home Page Figure 10.62 Programmatic Interfaces to XMethods 503 504 CHAPTER 10 • Web Services Figure 10.63 Web Services Explorer—WSIL Page 3. Click the WSIL Page icon (the page with globe) at the top right corner of the Web Services Explorer to open the WSIL page in the Navigator pane (see Figure 10.63). Paste in the XMethods WSIL URL http://www.xmethods.net/inspection.wsil select WSDL Services, and click the Go button. 4. The List All WSDL Services page is displayed (see Figure 10.64). View the list of WSDL services registered at XMethods. 5. You are now going to create your own WSIL document for League Planet. Use the New File wizard to create a new inspection.wsil file in the IceHockeyService/WebContent folder (see Figure 10.65). 6. You will now use WTP to generate WSIL files for the two League Planet Web services and then merge them into the root inspection.wsil file. Select QuerySOAPPort.wsdl and execute the Web Services ᭤ Generate WSIL command to create the QuerySOAPPort.wsil file. Repeat this for Update.wsdl. Merge the contents of these two generated WSIL files into inspection.wsil and add abstracts to describe them. Import IceHockeyService/WebContent/inspection.wsil Iteration 6: Discovering and Publishing Web Services 505 Figure 10.64 Web Services Explorer—List All WSDL Services Page Figure 10.65 New File—inspection.wsil before proceeding (see Example 10.16). You now have a WSIL document for the League Planet Web site. Example 10.16 Listing of inspection.wsil <?xml version="1.0" encoding="UTF-8"?> <inspection xmlns="http://schemas.xmlsoap.org/ws/2001/10/inspection/" xmlns:wsilwsdl="http://schemas.xmlsoap.org/ws/2001/10/inspection/wsdl/" xmlns:wsiluddi="http://schemas.xmlsoap.org/ws/2001/10/inspection/uddi/" xmlns:uddi="urn:uddi-org:api"> <service> <abstract xml:lang="en-US"> This Web service lets you query the League Planet Web site for schedule information. </abstract> <description referencedNamespace="http://schemas.xmlsoap.org/wsdl/" location="wsdl/QuerySOAPPort.wsdl"> <wsilwsdl:reference endpointPresent="true"> <wsilwsdl:referencedService xmlns:impl="http://leagueplanet.com/ws/query/"> impl:QueryService </wsilwsdl:referencedService> </wsilwsdl:reference> </description> </service> <service> <abstract xml:lang="en-US"> This Web service lets you query the League Planet Web site for game details and update the scores. </abstract> <description referencedNamespace="http://schemas.xmlsoap.org/wsdl/" location="wsdl/Update.wsdl"> <wsilwsdl:reference endpointPresent="true"> <wsilwsdl:referencedService xmlns:impl="http://leagueplanet.com"> impl:UpdateService </wsilwsdl:referencedService> </wsilwsdl:reference> </description> </service> </inspection> 7. Enter the URL http://localhost:8080/IceHockeyService/inspection.wsil in the Web Services Explorer WSIL page, select WSDL Services and click Go (see Figure 10.66). 8. The List All WSDL Services page is displayed (see Figure 10.67). View the WSDL services available at League Planet. Click the QuerySOAPPort.wsdl link. 506 CHAPTER 10 • Web Services Iteration 6: Discovering and Publishing Web Services 507 Figure 10.66 Web Services Explorer—Open WSIL for League Planet Figure 10.67 Web Services Explorer—List All WSDL Services for League Planet 508 CHAPTER 10 • Web Services Figure 10.68 Web Services Explorer—WSIL Service Details for QuerySOAPPort.wsdl 9. The WSIL Service Details page is displayed (see Figure 10.68). View the QuerySOAPPort.wsdl details. Summary of Iteration 6 In this iteration you used the Web Services Explorer to view information published in a UDDI registry and in WSIL documents. You also used WTP to create a WSIL document for League Planet. Summary In this chapter you have covered all the major functional areas of Web service development that are available in WTP. You created Web services using both the Top-Down and Bottom-Up approaches, generated a Java client proxy to access a Web service, developed a Web application that invoked the client proxy using the JAX-RPC programming model, validated Web services for WS-I compliance, tested Web services using both the Web Services Explorer and the JSP test client, viewed information published in both UDDI and WSIL, and created your own WSIL. Your are now ready to use Web services in your own applications. For further details about the tools, consult the WTP Help and Web site. [...]... for tests of your Web applications Typical Web applications will take much longer than 0.04 seconds to respond to page requests Unlike the previous iterations, to implement and run this test you will use a manual test tool The Eclipse Test and Performance Tools Platform (TPTP) (see the Installing TPTP sidebar) is a top-level Eclipse project like WTP that contains tools for executing Web application performance... com.meterware.httpunit.WebResponse; com.meterware.httpunit.WebTable; public class UpdateScoreTest extends TestCase { public void testUpdateScore() { Iteration 3: System Testing with HttpUnit 531 try { WebConversation wc = new WebConversation(); // Get the schedule page WebResponse resp = wc getResponse("http://localhost :80 80/IceHockeyServiceClient/" + "schedule?scheduleId=1"); // Get the schedule table WebTable scheduleTable = resp.getTables()[0];... it in the Java source editor 4 Edit UpdateScoreTest .java (see Example 11.5) Example 11.5 Listing of UpdateScoreTest .java package com.leagueplanet.systemtest; import junit.framework.TestCase; import import import import import import com.meterware.httpunit.TableCell; com.meterware.httpunit.WebConversation; com.meterware.httpunit.WebForm; com.meterware.httpunit.WebLink; com.meterware.httpunit.WebResponse;... -Dcactus.contextURL=http://localhost :80 80/icehockey Figure 11.7 Specify the Context URL for Cactus Tests Click Run The test is run and the results are displayed in the JUnit view (see Figure 11 .8) , Again, the bar is green because the test passed Summary of Iteration 2 In this iteration you created a new test source folder in the IceHockeyWeb project You then created a new Cactus servlet integration test for LoginServlet .java 5 28 CHAPTER... system test in the existing IceHockeyWebTest project In order to use HttpUnit, you need to add HttpUnit and its required libraries to your project Since the IceHockeyWebTest project is a dynamic Web project, you can simply place the libraries in the following folder, where they will automatically be picked up and registered for the project: IceHockeyWebTest/WebContent /WEB- INF/lib Copy the following libraries... creating a new dynamic Web project to hold your tests will allow you to continue to work in the J2EE perspective Here you create a new test project by doing the following: 514 CHAPTER 11 • Testing 1 In the Project Explorer view, use the New Dynamic Web Project wizard to create a project named IceHockeyWebTest For detailed information on creating Web projects, refer to the Creating Web Applications section... displayed The Java version set on the IceHockeyWebTest project needs to be the same as the version set on the IceHockeyWeb project Ensure that the Java version is set to the same level as the IceHockeyWeb project The level will be the same as the Tomcat JDK 3 Accept defaults for other options and click Finish WTP creates the project in your workspace 4 To test the contents of the IceHockeyWeb project,... the client side Java Web applications have strict class loading rules, and therefore your tests cannot be separated into a different project as was the case with JUnit for unit tests For servlet integration tests your test cases must be contained within the same Web module that contains the servlets You will add the servlet test case to the IceHockeyWeb project that contains LoginServlet .java However,... dependency on that project Right click on the IceHockeyWebTest project and select Properties The Properties window for IceHockeyWebTest opens Select Java Build Path from the menu on the left if it is not already selected Select the Projects tab on the Java Build Path page Click the Add button The Required Project Selection dialog opens Select the IceHockeyWeb project and click OK The dependency is added... the change While JUnit and Cactus can be used to create system tests for Web applications, they are not a natural fit for these tests since JUnit has no built-in support for interacting with Web applications and Cactus focuses on individual servlets, not end-to-end scenarios Although it is typical for an end user to interact with a Web site using a browser, looking at the interaction from a technical . Planet 5 08 CHAPTER 10 • Web Services Figure 10. 68 Web Services Explorer—WSIL Service Details for QuerySOAPPort.wsdl 9. The WSIL Service Details page is displayed (see Figure 10. 68) . View the QuerySOAPPort.wsdl. view, use the New Dynamic Web Project wizard to create a project named IceHockeyWebTest. For detailed information on creating Web projects, refer to the Creating Web Applications section in Chapter. The Java version set on the IceHockeyWebTest project needs to be the same as the version set on the IceHockeyWeb project. Ensure that the Java version is set to the same level as the IceHockeyWeb