Create Web Services

Web services are self-contained applications, based on open standards, that can be invoked over the Web. Web services provide a way for applications to connect and interact easily and efficiently. They can be building blocks of applications used within your enterprise or provide a point of interaction with other enterprises. Because their interfaces are defined according to standards, Web services can interact with other applications that are not Java-based. Using a combination of tools from HATS Studio and WebSphere Studio, you can create Web services from Integration Objects or from EJB Access Beans. You can also create Web service clients that access the Web services.

You cannot include an Integration Object that is configured to use Web Express Logon in a Web service.

Web services use several standard ways to formulate information: Simple Object Access Protocol (SOAP), Web Service Description Language (WSDL), and Universal Description, Discovery, and Integration (UDDI). This book refers to but does not explain these protocols. You can find information about them by opening the WebSphere Studio documentation (click Help > Help Contents from any WebSphere Studio perspective) and searching for "Web service".

Usually you will build Web services based on Integration Objects that you have already built, tested, and deployed. This chapter assumes that you have one or more successfully tested Integration Objects that you want to include in a Web service. However, you can start from the very beginning by opening your host terminal, recording one or more macros, creating Integration Objects from the macros, and testing the Integration Objects. Refer to HATS User's and Administrator's Guide for information about creating an Integration Object from a macro.

You must decide whether you want your Web service to comply with the Web Services Interoperability (WSI) standard. This will govern which Web service runtime you use for the creation of your Web services. If you accept the default, the WebSphere Application Server Version 5.0.2 runtime, the resulting Web service will be WSI-compliant.

You must follow certain naming conventions when creating Web services using the WebSphere Application Server Version 5.0.2 runtime. These include:

Keep these naming restrictions in mind when creating macro names, prompt names, and extract names during macro creation. For more information on naming restrictions, refer to the WebSphere Studio documentation.

 

Create a Web service from Integration Objects

To create a Web service, begin from the HATS Project View and follow these steps:

  1. Expand the project that contains the Integration Objects you wish to use, then expand the Source folder and the IntegrationObject folder.
  2. Right click on any Integration Object in your project and select Create HATS Web Services Support Files.
  3. The Create HATS Web Services Support Files wizard enables you to choose any project as the source of the Integration Objects you will include in a Web service. The project in which you clicked will be the default. Provide a class name for the HATS Web service support files. The class name must begin with an uppercase letter. We will refer to this class as your wrapper class for this Web service. This wrapper class enables you to choose a logical group of Integration Objects or EJB Access Beans to include in one Web service. For example, you might choose to include all the Integration Objects in a chain in the wrapper class. To see a list of Integration Objects and choose the ones to include, click Next.
  4. Select the resources (Integration Objects and EJB access beans) that you want to include in your Web service, then click Finish. HATS will create a set of classes to be used in creating the Web service. These classes will appear in the HATS Project View in the webServiceClasses folder, under the Source folder:

    • The wrapper class that you specified. This wrapper class contains an io_nameProcessWS()method for each Integration Object that you chose to include in the wrapper class. When you create the Web service using WebSphere Studio Wizards, you will be creating a Web service that contains all of the io_nameProcessWS() methods contained in the wrapper class.
    • Input properties classes (io_name_Input_Properties) for each Integration Object that you included in the wrapper class. The input properties class will be used to set all the necessary inputs for the Integration Object.
    • Output properties classes (io_name_Output_Properties) for each Integration Object that you included in the wrapper class. All of the the Integration Object output properties can be retrieved fom the output properties class.

  5. Click the Navigator tab to open the Navigator view of your resources. Expand your project, then expand Java Source and webServiceClasses. Right click the wrapper class that you created, and select Web Services > Deploy as Web service. Use the IBM WebSphere 5.0.2 Web service runtime; it provides the most standard-compliant code and supports the most clients. You can click Finish or click Next to view and choose different options, which are described in the WebSphere Studio documentation. When you have made all your choices, click Finish. WebSphere Studio will create a Web Services Description Language (WSDL) file that describes the interfaces to your Web service.

    If you choose the WAS 5.0.2 runtime, one WDSL file will be created, named wrapper.wsdl, where wrapper is the name you gave to your wrapper class. If you choose the IBM SOAP runtime, four WSDL files will be created. When you create your Web service client, you will use the file named wrapperService.wsdl.

  6. Go to Testing your Web service with Web Services Explorer for information about testing your Web service before you create a client.

 

Create a web service from EJB Access Beans

If you have created a HATS EJB project, as described in Create and Using a HATS EJB application, you can create a Web service to use the services of the Integration Objects in the HATS EJB project. To create a Web service, have another HATS project, within the same Enterprise Archive (.ear file) as your HATS EJB project. We will call this your target project, in which a Web service will be created from the EJB Access Beans you choose. Follow these steps to create the Web service:

  1. In the HATS EJB Project View, right-click on one of your Integration Objects and select Export EJB Access Bean to HATS Project. In the Export EJB Access Bean dialog, select the Integration Objects for which you want to export EJB Access Beans. Select the target project from the drop-down list of available projects. Click Finish.
  2. In the HATS Project View, expand the target project, the Source directory, and the IntegrationObject directory. You will see items in this directory with the name io_name_Access, where io_name is the name of the Integration Object from which the access bean was created.
  3. Right click on any of these access beans and select Create HATS Web Services Support Files.
  4. Follow the steps beginning with step 3 in the list under Create a Web service from Integration Objects.

 

Testing your Web service with Web Services Explorer

You can test your Web service in WebSphere Studio before you create a client application. In the Navigator view, expand your project, expand Web Content, wsdl, and webServiceClasses. If you created your Web service using the WAS 5.0.2 runtime, this folder contains a file called wrapper.wsdl, where wrapper is the name you gave to your wrapper class. If you created your Web service using the IBM SOAP runtime, this folder contains several wsdl files; use the one named wrapperService.wsdl. Right click this file and select Web Services > Test with Web Services Explorer.

In the right pane of the Web Services Explorer, you will see the io_nameProcessWS()methods for each Integration Object or EJB Access Bean included in the Web service. Click any method name to test that Integration Object. You will see a list of the input properties that you can specify for the Integration Object. This list is based on the Integration Object's io_name_Input_Properties class. The only properties that must be set are the prompts that you defined when you recorded your macro. The other properties can be left blank. Refer to the WebSphere Studio documentation for information about using the WSDL view of Web Services Explorer to explore and test your Web service definition.

 

Create a Web service client

Next you can create a client application to use the Web service. Follow these steps:

  1. In the Navigator view, expand your project, expand Web Content, wsdl, and webServiceClasses. This folder contains a file called wrapper.wsdl, where wrapper is the name you gave to your wrapper class, or wrapperService.wsdl if you created your Web service with the IBM SOAP runtime.
  2. Right click this file and select Web Services > Generate Client to start the WSDL to JavaBean Proxy wizard. On the first page of the wizard, click Test the generated proxy if you want the wizard to create sample JSP pages. On the second page of the wizard, choose the project that will contain your client code. The client project must be a different project from your Web service project. If you want a new project created, you can type in a new project name in the Client Web Project field. The runtime protocol for the client must match that used for the Web service. Refer to the WebSphere Studio documentation for information about the options in this wizard. When you have made all your choices, click Finish.
  3. If you click Test the generated proxy, the wizard will create sample JSP pages, which you can use as a starting point for code to drive your Web service. In the Navigator view, expand your client project, then expand Web Content and sample. In the sample folder will be a directory with the name of your wrapper class. Expand that folder to view the list of JSP pages. You can run the sample by running the TestClient.jsp on the server. Remember that you only need to set the input properties that correspond to macro prompts. Double click Result.jsp to open it in the JSP editor. You can examine the code, and copy code from the sample into a HATS business logic class that will be executed from a screen customization, to invoke your Web service and use the output in a transformation or in some other way.

 

Programming with Web Services Integration Objects and EJB Access Beans

 

Integration Object chaining with Web Services

If your application requires chaining, your client code must retrieve the hPubLinkKey property from the first Integration Object in the chain, and set it for all subsequent Integration Objects in the chain.

 

EJB Access Bean chaining with Web Services

If your application requires chaining, your client code must retrieve both the hPubLinkKey and the hPubAccessHandle properties from the first EJB Access Bean in the chain, and set them for all subsequent EJB Access Beans in the chain

 

Home