< Previous | Next >

Lesson 2: Set up the service

Now that you have written the code for this service, you can make it available to other applications as a web service. Making the service available in this way involves creating service binding information, which tells other applications where to find the service and what functions are available in the service. The service publishes this information as a Web Services Description Language (WSDL) file.

As an alternative to web services, EGL client applications can access EGL service applications as EGL services. This method offers better performance then web services, but it can be used only between two EGL applications. For the broadest compatibility, this tutorial uses web services, which can be used between two EGL applications, two non-EGL applications, or an EGL application and a non-EGL application. For more information, see the EGL documentation by clicking Help > Help Contents.

Service binding information is contained in an EGL deployment descriptor. In these steps, you work with the project's deployment descriptor and configure the project's build descriptor to use that deployment descriptor.

Verify the deployment descriptor and build descriptor

When you created the EGL project, you automatically created a deployment descriptor file named EGLService.egldd. Then, when you created the service, you selected the Create as web service check box, which automatically added the service to the deployment descriptor. In this section, you verify these settings.
  1. In the Project Navigator view, expand the EGLService project and the EGLSource folder. Open the EGL deployment descriptor file by double-clicking the EGLService.egldd file.
  2. In the EGL deployment descriptor editor, click the Web Service Deployment tab.
  3. Make sure that your service is shown in the list of services to be deployed as web services, as in the following picture:
    The EGL web service deployment tab
  4. Close the deployment descriptor file.
  5. Double-click the build descriptor for the project to open it in the build parts editor. This file is named EGLService.eglbld and is located in the project's EGLSource folder. The build descriptor file contains build descriptor options, which describe how EGL will generate your project into the output language.
  6. In the list of build descriptor options, find the option named deploymentDescriptor. Note that it is set to the name of the deployment descriptor, which has the same name as the project by default. The deployment descriptor must be referenced in this way to be used. The build parts editor looks like this, with the value of serverType appropriate to your version of WebSphere Application Server:
    The build parts editor, showing the deploymentDescriptor option set to the name of the deployment descriptor
  7. Close the build descriptor.
  8. Generate the entire project by right-clicking the project in the Project Explorer view and then clicking Generate.

Generate the WSDL file

WSDL files communicate information about services to clients, describing the functions provided in the service and specifying the location of the service. In this section, you generate a WSDL file from the service. Later, your client application will import this WSDL file and use the information in it.

EGL uses the information in the deployment descriptor file and the service part itself to generate a WSDL file, but it needs one more piece of information: on which port the server will host the service. By default, the port is 9080. Follow these steps to find out the port number of your server:

  1. Open the Servers view. If you can't find the Servers view, click Window > Show View > Servers.
  2. Right-click the server named WebSphere Application Server. At the popup menu, add EGLServiceEAR by clicking Add and Remove and then start the server by clicking Start. The server may take some time to start, depending on your system.
  3. Wait until the server shows Started, Synchronized in its Status field, as shown in this picture:
    The Servers view with the server started
  4. When the server has started, right-click it in the Servers view and then click Run administrative console, not Run administrative script. The administrative console opens in the editor.
  5. At the left side of the administrative console, expand Servers and click Application servers. Your server is shown as a listing under Application servers, as in this picture:
    List of servers in the administrative console
  6. Click the server name in the Name column.
  7. On the page describing your server, click the Configuration tab.
  8. On the Configuration tab, under Communications, click the Ports link.
  9. From the list of ports, click the port with the Port Name labeled WC_defaulthost.
  10. On the page describing this port, write down the port number in the Port field. In this picture, the port number is 9082.
    Administrative console showing the port number
  11. Close the administrative console without making any changes.
  12. In the top menu, click Window > Preferences.... In the left panel, expand EGL and click Services.
  13. If the entry for the Port field does not match the server port number in the administrative console, enter the port number from the console here. The window looks like this:
    The Service preference shows the same port number for WSDL generation as the server does.
  14. Click Finish.
  15. In the Project Explorer view, right-click the HelloService.egl file, which is in the services package of the EGLSource folder, and then click EGL Services > Generate WSDL File.
  16. In the Create WSDL File window, click Finish. EGL creates a WSDL file in the wsdl package of the EGLSource folder and displays it graphically in the WSDL editor.
  17. Examine the graphical representation of the WSDL file and close it when you are finished.
Now you have configured the service to be used by other applications at run time. The WSDL file describes the service so that clients can connect to it at run time, and the deployment descriptor file allows EGL to make the service available at run time.

In the real world, services run independently of the clients that use them. To simulate this situation, you could create a new instance of the application server and run the service there. For the sake of this tutorial, there is no advantage to consuming these additional resources, so you will run the service on your existing application server at the time you test your client.

< Previous | Next >

Feedback