Skip to main content

Modifying an SCA module in WebSphere ESB to use the Web Services Feature Pack

Ying Ji Sun (sunyj@cn.ibm.com), Software Engineer, IBM
Ying Ji Sun is a Software Engineer at the IBM China Development Lab. He currently works on the WebSphere Enterprise Service Bus function validation test team. You can contact Ying Ji at sunyj@cn.ibm.com.
Simon Holdsworth is a Software Architect for WebSphere business integration products at the IBM Hursley Software Lab in the UK. He works on the WebSphere Enterprise Service Bus and WebSphere Process Server teams, and is the editor of the SCA, JMS, and Web services bindings specifications on osoa.org. His previous IBM roles include development positions on Web Services Gateway, MQSeries Integrator, Component Broker, DSOM, and CICS. He has an MSc in Mathematical Logic and the Theory of Computation from Bristol University, UK. You can contact Simon at simon_holdsworth@uk.ibm.com.
Jim Ramaker (ramaker@us.ibm.com), Managing Editor, developerWorks WebSphere Web site team, IBM
Jim Ramaker is the Managing Editor of the developerWorks WebSphere Web site team at IBM Silicon Valley Lab in San Jose, CA. He is an editor for the following WebSphere products: WebSphere Enterprise Service Bus, WebSphere Message Broker, WebSphere MQ, and WebSphere DataPower SOA Appliances. You can contact Jim at ramaker@us.ibm.com.

Summary:  This article shows you how to modify an SCA module in WebSphere ESB to include the WebSphere Web Services Feature Pack and gain access to the additional qualities of service that it provides, both for invoking Web services and for providing them in an SCA module.

Date:  10 Dec 2008
Level:  Intermediate
Activity:  384 views
Comments:  

1. Introduction

The following diagram illustrates an SCA mediation module that has been modified to include use of the Web Services Feature Pack (WSFEP). To provide a Web service endpoint using the WSFEP, a router module has been added containing a bridging bean that provides an alternative to an SCA export for receiving Web service requests. To invoke a Web service using the WSFEP, a custom Java bridging component has been added as an alternative to an SCA import. These two modifications may be done individually in a module or together as shown for this mediation module:


Figure 1. Bridge scenario in SCA module
Bridge scenario in SCA module
  • In the WSFEP module, the Bridging bean is a JAX-WS-enabled Java bean that provides a Web service endpoint, and calls an SCA component via standalone reference.
  • In the SCA mediation module, the Bridging component is an SCA POJO component that uses a JAX-WS API to invoke a Web service.
  • These two artifacts are represented in the application as two independent WSFEP endpoints, each with its own policy set configuration.

2. Setting up the development and runtime environments

2.1. Installing the runtime

The example in this article needs to run in a clean environment, so please do not create any profiles in the first two steps:

  1. Install WebSphere ESB V6.1.2, which includes both WebSphere Application Server V6.1.0.17 and WebSphere ESB V6.1.2.
  2. Install WSFEP.
  3. Update with the package 6.1.0.9-WS-WASWebSvc-IFPK53084.pak.
  4. Update with the package 6.1.0-WS-WASWebSvc-WinX32-FP0000017.pak.

For newer versions of the products, there may be some differences, so you should create a WSFEP standalone server with a name such as AppSrv01, and augment it with the WebSphere ESB profile. Your versions of WebSphere Application Server and WSFEP can be different from those in this article, but they must match each other.

2.2. Installing development tools

  1. Install Rational Application Developer V7.0.0.0.
  2. Update package with Installation Manager till you get Rational Application Developer V7.0.0.6 and WebSphere Integration Developer V6.1.0.100

3. Implementation

3.1. Outline

This section describes the combined scenario in a mediation module. If you want, you can implement the individual endpoint enablement and invocation separately. Three artifacts combine to create the bridge scenario application:

WS FEP-Service
Provides a JAX-WS Web service that will eventually be invoked by the bridging component in the SCA Mediation Module.
Bridge-application
A WSFEP-enhanced SCA mediation module that can invoke and be invoked by applications that require the additional qualities of service supported by the WSFEP, such as SOAP 1.2 and WS-RM.
Client
A JAX-WS client application to invoke a Web service provided by the Bridge-application.

After building the artifacts, export them to EAR files and deploy them to the server for testing. You can add policy sets to the EAR files to apply the new Web services policies introduced by WSFEP.

3.2. Developing WSFEP-Service

This section describes how to create a Web service provider application that uses the WSFEP. This application will be called from the Bridge-application described in the next section.

  1. Open Rational Application Developer and create a new workspace.
  2. Select Windows => Preferences => Installed Runtime => New Server Runtime.
  3. The type of runtime should be WebSphere Application Server V6.1, and should point to your installation directory.
  4. Create a new Dynamic Web Module and set the Target runtime to your newly created Server Runtime. Click Next.
  5. In the next screen, check WebSphere V6.1 Feature Pack for Web Services and click Finish.
  6. We have provided a Java POJO class named GreeterImpl.java, which implements the basic function of the Web service to be used as the inbound service endpoint to bridge to the SCA component.

    Service implementation
    package services.impl;
    public class GreeterImpl{
      public String sayHi() {
        return "Hi";
      }
      public String greetMe(String requestType) {
        return "hello " + requestType;
      }
      public void greetMeOneWay(String requestType) {
      }
    }
    

  7. Create a package named services.impl and copy the Java file in.
  8. Create a Web service in the workspace and set Service Implementation to services.impl.GreeterImpl. Change Web service runtime to IBM WebSphere JAX-WS. Adjust the level to Assemble service and click Next.
  9. In the following screen, check Generate WSDL file into project and click Finish:

    Figure 2. Files and folders generated for Web service server by Rational Application Developer
    Files and folders generated for Web service server by Rational Application Developer

Now you have a WS FEP enhanced Web service.

3.3. Developing the Bridge-application

This section describes how to develop an SCA mediation module that invokes Web services and exposes a Web service endpoint using the WSFEP, which is effectively the same as having a WSFEP-enabled import and export binding in the module. The steps apply to any SCA module, and can be applied separately to invoke a Web service or expose a Web service in an SCA module.

  1. In the same workspace, click File => New => Mediation Module to create an SCA Mediation Module named SCAModule. Set its Target Runtime to WebSphere Process Server V6.1.
  2. Under the Data Types node, create a new BO named StrObj with a string-typed attribute value named val. This BO is used to carry information in the mediation module.
  3. Create an interface named SCAIntf and add an operation named greetMe, whose input and output are type StrObj.
  4. Add an Interface and a Reference to the mediation component.
  5. Add a standalone reference and a Java component and link them to the SCA module. Accept the default settings.
  6. Double click SCAModule and link up in the request flow and response flow.
  7. In the next a few steps you will modify the Java component to enable the SCA module to access the WSFEP Web service. But before modifying the Java component, you need to create some additional artifacts that it uses to access the Web service. Rational Application Developer can generate the artifacts automatically.
  8. Create a Java project named WSFEPClient, which is a temporary project used to generate some artifacts with WSFEP features that are not easily generated in a non-WSFEP-enhanced project. In the project, create a Web Service Client. Set the Service definition to GreeterImplService.wsdl from WSFEPService module.
  9. Set Web service runtime to IBM WebSphere JAX-WS and click Finish. New files are generated in the package services.impl, which you will use in the Java component in SCAModule.

    Figure 3. Files and folders generated for Web service client by Rational Application Developer
    Files and folders generated for Web service client by Rational Application Developer

  10. Copy the package into SCAModule. To solve the compile errors, add as an external JAR <WAS_ROOT>/runtimes/com.ibm.jaxws.thinclient_6.1.0.jar.
  11. Modify the Java component. Add the following snippet under the function greetMe. Press Ctrl + Shift + O to import the classes needed:

    Sample code in the Java component
    
    public DataObject greetMe(DataObject input1) {
    //TODO Needs to be implemented.
      System.out.println("into java component");
      String name = input1.getString("val");
      try{
        GreeterImplDelegate port = (new GreeterImplService()).getGreeterImplPort();
        input1.setString("val", port.greetMe(name));
      }catch(Exception ex){
        ex.printStackTrace();
        System.out.println(ex.getMessage());
        input1.setString("val", "Error in java component");
      }
      return input1;
    }
    

  12. Now you have an SCA module that can invoke a Web service using WSFEP. In the following steps, you will enhance the SCA module so that it can provide a WSFEP-enabled Web service.
  13. Create a new Dynamic Web Module and name it to Your SCA module name + Web (in this sample, SCAModuleWeb). You must follow this name conversion to add the Web module to your SCA module application. Add the project to your SCAModuleApp.
  14. Change the Targeted runtime of the SCAModuleWeb to WebSphere Application Server V6.1(2) (which contains the WS-FEP features), and add Library => Server runtime => WPS.
  15. Create a package named scaServiceWeb.impl, a Java class named SCAServiceWebImpl, and add a method as shown below. Keep the method name greetMe, corresponding with the one in SCA module interface, although this is not essential. The code is used to invoke the SCAModule standalone reference.

    Sample service implementation in SCA module
    
    import com.ibm.websphere.bo.BOFactory;
    import com.ibm.websphere.sca.Service;
    import com.ibm.websphere.sca.ServiceManager;
    import commonj.sdo.DataObject; 
    public String greetMe(String requestType) {
      String ref = "SCAIntfPartner";
      String wsdlOperation = "greetMe";
      String rtnStr = "error";
      try {
        ServiceManager sm = new ServiceManager();
        Service service = (Service) sm.locateService(ref);
        BOFactory bof = (BOFactory) sm.locateService("com/ibm/websphere/bo/BOFactory");
        DataObject inWrapper=
            bof.createByElement("http://SCAModule/SCAIntf",wsdlOperation);
        DataObject input = inWrapper.createDataObject("input1");
        input.setString("val", requestType);
        System.out.println("invoking");
        DataObject output = (DataObject) service.invoke(wsdlOperation,input);
        System.out.println("invoked");
        if (output!=null) {
          System.out.println("Result" + output.getString("val"));
          rtnStr = output.getString("val");
        }else{
          System.out.println("Null");
        }
      } catch (Exception e) {
        System.out.println(e);
      }
      return rtnStr;
    }
    

  16. Use this Java file to create a Dynamic Web Module. Set the Service implementation to scaServiceWeb.impl.SCAServiceWebImpl and set Web service runtime to WebSphere JAX-WS.
  17. Check Generate WSDL file into the project on the next page and click Finish. You will see the familiar folders and files like those in Figure 2.
  18. Now you have a WSFEP-enhanced SCA module that provides a WSFEP-enabled Web service. You can attach a policy set here, as described below.

3.4. Developing a client application

This section describes how to develop a client application that you can use to call the module you have just completed.

  1. The procedure of developing a client application is similar to Step 9 under Developing Bridge-application, except that you set the service definition to SCAServiceWebImplService.wsdl from SCAModuleWeb.
  2. Create a standalone Java project to invoke the WSFEP Web service provided by SCAModule with the snippet below. Press Ctrl + Shift + O to import the classes needed and add the following code:

    Sample code in client project to invoke Web service
    public static void main(String[] args) {
    // TODO Auto-generated method stub
      try{
        SCAServiceWebImplDelegate port = (new SCAServiceWebImplService())
          .getSCAServiceWebImplPort();
        System.out.println(port.greetMe("sunyj"));
      }catch(Exception ex){
        ex.printStackTrace();
      }
    }
    

3.5. Deploying EAR files

Now that you have finished developing the bridged application, you can deploy the projects:

  1. Export SCAModuleApp to SCAModuleApp.ear.
  2. Export WSFEPServiceEAR to WSFEPServiceEAR.ear.
  3. Deploy the two EAR files to the application server and start them using the Admin Console.
  4. Run Client.java. You should get a return value of hello sunyj.

3.6. Attaching a policy set

The main reason for using the WSFEP runtime is so you can configure the additional qualities of service it provides, which is done using policy sets. This section shows you how to add a policy set to the Web service endpoints you added to the SCA module earlier. Use WSAddressing default as an example:

  1. Right-click on SCAModuleWeb and select New => Others => Server Side Policy Set Attachment.
  2. Select WSAddressing default. Service Ear Project should be SCAModuleApp. You have now finished adding a policy set to the server side:

    Figure 4. Adding policy set attachment to server side application
    Adding policy set attachment to server side application

  3. Right-click on Client and select New => Others => Client Side Policy Set Attachment.
  4. Select WSAddressing default, enter Default Binding, and click Finish.
  5. If you are using a standalone Java project as the client, use the policy set in the download file at the bottom of this article, instead of the one generated by Rational Application Developer.

You have now finished adding a policy set to both sides of WS endpoint, as shown above in Figure 1. Next you associate the policy set with the Bridging Component. Use WSReliableMessageing as an example:

  1. Select WSFEPService and create a Service Side Policy Set Attachment. Use WSReliableMessageing default as an example. Set Service Ear Project to WSFEPServiceEAR and click Finish. Because the SCAModule is built on a WebSphere Process Server runtime, you cannot use the method to create JAX-WS client code with the Rational Application Developer wizard, so you cannot directly add the Client Side Policy Set Attachment. Instead:
  2. Select WSFEPClient and create a Client Side Policy Set Attachment. In the Policy Set drop-down list, select WSReliableMessaging default and enter Default Binding in Binding. Click OK => Finish.
  3. Several files are generated in META-INF. Export SCAModule to SCAModuleApp.ear and copy these files into SCAModuleApp.ear\META-INF\.

You have now finished adding a policy set to both sides of the Bridging Component. Next you need to redeploy the EAR files. In the Admin Console, select Enterprise Applications => SCAModuleApp => Service provider policy sets and bindings. The policy set has been attached to the application. Figure 5 shows the service provider policy sets and bindings for the Bridging Component:


Figure 5. Policy set information sample seen in Admin Console
Policy set information sample seen in Admin Console

4. Running the result

  1. Run Client.java as an application. You should get the return value hello sunyj.
  2. If you examine the request/response message in WS endpoint (Figure 1), you will see that the snippets below are added to the messages:

    Figure 6. Snippet in request/response message of WSAddressing
    Snippet in request/response message of WSAddressing

  3. If you examine the request/response message in the Bridging component (Figure 1), you will see that the snippets below are added to the messages:

    Figure 7. Snippet in request/response message of WSReliableMessaging
    Snippet in request/response message of WSReliableMessaging



Download

DescriptionNameSizeDownload method
Standalone java client policy set of WSAddressingjava_client_policy_set.zip3 KBHTTP

Information about download methods


Resources

About the authors

Ying Ji Sun is a Software Engineer at the IBM China Development Lab. He currently works on the WebSphere Enterprise Service Bus function validation test team. You can contact Ying Ji at sunyj@cn.ibm.com.

Simon Holdsworth is a Software Architect for WebSphere business integration products at the IBM Hursley Software Lab in the UK. He works on the WebSphere Enterprise Service Bus and WebSphere Process Server teams, and is the editor of the SCA, JMS, and Web services bindings specifications on osoa.org. His previous IBM roles include development positions on Web Services Gateway, MQSeries Integrator, Component Broker, DSOM, and CICS. He has an MSc in Mathematical Logic and the Theory of Computation from Bristol University, UK. You can contact Simon at simon_holdsworth@uk.ibm.com.

Jim Ramaker is the Managing Editor of the developerWorks WebSphere Web site team at IBM Silicon Valley Lab in San Jose, CA. He is an editor for the following WebSphere products: WebSphere Enterprise Service Bus, WebSphere Message Broker, WebSphere MQ, and WebSphere DataPower SOA Appliances. You can contact Jim at ramaker@us.ibm.com.

Comments



Trademarks  |  My developerWorks terms and conditions

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=WebSphere, Rational
ArticleID=358199
ArticleTitle=Modifying an SCA module in WebSphere ESB to use the Web Services Feature Pack
publish-date=12102008
author1-email=sunyj@cn.ibm.com
author1-email-cc=
author2-email=simon_holdsworth@uk.ibm.com
author2-email-cc=
author3-email=ramaker@us.ibm.com
author3-email-cc=

My developerWorks community

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Rate a product. Write a review.

Special offers