 | Consuming a third-party Web service
The steps you will perform in this section are:
-
Get a third party WSDL file from the Internet.
-
Generate Web service and Client bindings.
-
This will generate the code that will allow you to access the functions defined in the WSDL file.
-
Test the third-party Web service by creating a Web page.
Start by finding a service and its WSDL file.
Find a third-party service
You can speed up this process by using the WSDL provided on your disk, and proceed to the heading: Create an EGL Web Project.
You are now going to consume a third-party Web service. To do this you must have a working Internet connection.
-
Point your browser to www.xmethods.net.
-
On the homepage, click the [View the Full List] link, as shown in Figure 27.
Figure 27. XMethods home page
-
Find Ignyte’s Retrieve Theaters and Movie Showtimes and click the link, as shown in Figure 28.
Figure 28. Navigate to the Movie Showtimes application
-
Right-click the link in the row labeled WSDL, and select Save Link As, as shown in Figure 29.
Figure 29. Save the application
locally
-
Save the file to your C:\ drive. Make sure to select All Files as the Save as type, and save the file with a .wsdl extension.
Figure 30. Saving the file
Now that you have a WSDL file that describes a service that provides information about movies playing in a certain area of the United States, you can write an EGL application that displays the data provided by this service.
Create a new EGL Web project
-
In the Rational Developer for System i SOA workbench, in the Web perspective (Figure 31):
-
Select File > New > Project > EGL > EGL project.
-
Name it
Lab7_Web_Service.
-
Make sure that Web Project is selected.
-
Click Next.
Figure 31. Enter project name and select project type
-
Make sure that WebSphere Application Server v6.1 is the selected Target Runtime, as shown in Figure 32.
-
Click Finish.
Figure 32. Specify the general settings for the EGL Web Project
Next, you need to create a services package. This package will contain the service information that EGL will extract from the WSDL file, as well as the WSDL file itself.
-
Right-click the EGL Source folder.
-
Select New > EGL Package, as shown in Figure 33.
Figure 33. Create a services package
-
Enter the Package name
services, as shown in Figure 34.
-
Click Finish.
Figure 34. Create an EGL Package
Now you need to copy the wsdl file (which you downloaded previously) into this package.
-
In Windows Explorer, expand the C:\ drive.
-
Right-click moviefunction.wsdl on the C:\ drive, as shown in Figure 35.
Figure 35. Select file to copy
-
Select copy
-
In the Rational Developer for System i SOA workbench, right-click the services package under the LAB7_Web_Service project and select Paste.
If you pasted the WSDL in the correct location, it should now appear in the services folder, as shown in Figure 36.
Figure 36. Location of moviefunctions.wsdl
Extract the services information
Next, extract the services information from the WSDL file.
-
Go back to the services package.
-
Right-click moviefunctions.wsdl and select EGL Services > Create EGL Client Interface,
Figure 37. Create a client interface
-
Click Next in the New EGL Part dialog, as shown in Figure 38.
Figure 38. Create EGL interfaces from a WSDL file
-
From the available functions shown in Figure 39, you could clear GetUpComingMovies (because you are only interested in GetTheatersandMovies), but leave the default.
-
Click Next.
Figure 39. Specify folder, package, file, and functions
You are now at the New EGL Web Client Binding view.
The Lab7_WebService deployment descriptor is the default to add the binding to.
-
Accept the defaults and click the Finish button, as shown in Figure 40.
Figure 40. Add EGL Web client bindings
An interface to a third-party Web service is created. You can use this service and reference it in (call it from) your EGL client business logic. The EGL source file containing the interface information of this service will be opened in the content area. It is called moviefunctions.egl and is contained in the com.ignyte.www package.
With all of the service information now available, you need to re-generate the project so that EGL can take this new information into consideration for this project.
-
Right click the project and click Generate, as shown in Figure 41.
Figure 41. Re-generate the project
The generation finishes.
|  |