Skip to Content
Author's profile photo Jenish Prabhu

Using Service Group in calling web services from EJB

Idea behind Service Group:

                Service group is configured with provider system, this helps to reduce configuration overhead and transport issues. This document explains how it really helps in terms of configuration overhead and transport issues.

                When we write EJB’s to invoke web service it takes the login parameter for web service from logon ticket or invocation parameter. Here we are going to see how to configure user account, so that for any particular web service invocation which uses the configured service group with user account, it will always use different logon credential.

How to create Service Group Configuration DC ?

Let’s proceed to create a new Service Group Configuration DC; in the example below we named the Service Group ECC_SG.

1. Create a Service Group Configuration Project

New Picture.png 
2.   Enter the DC name

New Picture (1).png

3.   Switch to Service Composer Perspective. Create a new Service Group under Connectivity

New Picture (2).png

4.   In this scenario, I am creating a non-classified Service Group

New Picture (3).png

5. Open the newly created Service Group to view details

New Picture (4).png

New Picture (5).png

6.  Build and deploy the DC.

To view the deployed DC in Portal, Go to Portal, http://host:port/nwa

In NWA, go to SOA -> Application and Scenario Communication -> Application Communication

New Picture (6).png

New Picture (7).png

How to configure Service Group

1. Log in to NWA Go to SOA > Application and Scenario Communication > Application Communication

2. Give the DC name for service group and search, it shows all the service group as below

New Picture (8).png

3. Click on Edit button and choose create from provider system as shown below

New Picture (9).png

4. It shows create screen as below, select required system name, system type to assign provider system

New Picture (10).png

5. Once service group is configured with provider system it shows green status as below

New Picture (11).png

How to invoke web service from EJB:

1. Right click on working DC, Import > WSDL and Open Import wsdl dialogue from NWDS

New Picture (12).png

2. Choose Remote Location / File System as below

New Picture (13).png

3. Give wsdl url and click on finish button

New Picture (14).png

4. Now wsdl file is downloaded in to the DC

5. Right-click on wsdl file and Web services > Create Service Reference as below

New Picture (15).png

6. In the New Service Reference dialogue choose existing service group that was already configured in the previous step explained before.

New Picture (16).png

7. After click on Finish button newly added service reference is appeared as below

New Picture (17).png

8. Now from the EJB call the web service as below

     (a)   Add local variable in EJB as below:

    

          @WebServiceRef

                TestService objTestService;

     (b) Invoking the web service

           TestBinding binding = objTestService.getPort(TestBinding.class);

           Return return = binding.invokeWS(arg1, arg2, ar3);

           String response = return.getMessage();

9. Go to NWA and SOA > Application and Scenario Communication > Application Communication

10. Type DC that is used for web service, go to Provider Services and Assign SAP_DEFAULT_PROFILE as shown below.

New Picture (18).png

Configure user account for service group:

1. Go to NWA and SOA > Application and Scenario Communication > User Account Management

2. Click on New and create new user account

New Picture (19).png

3. Click on Next and give connectivity type and metadata user/pass to invoke web service

New Picture (20).png

4. Go to assignment tab and click on new and choose “Test” user that was created earlier in the previous step

New Picture (21).png

5. Now click on Next button and choose provider system

New Picture (22).png

New Picture (23).png

6. Now newly created User account is showing provider system and service group as below

New Picture (24).png

Advantage of using service groups:

  • In the service group we define the provider system, which actually tells us the end point URL. By seeing service group program can generate end point URL to invoke the web service. We are grouping all the related web services as one entity and naming it as a group, so that it can be invoked with same credentials.
  • Using service group reduces the configuration and when ever transport happens, we don’t really change the end point url config every time. Service group tells us which system the service is present.
  • By configuring user account we can invoke all the web services in the provider system with the logon credentials that was defined when creating the account.

Assigned Tags

      2 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo GOVARDAN RAJ SHAMANNA
      GOVARDAN RAJ SHAMANNA

      HI prabhu

      nice blog , really help full.

      Regards

      Govardan

      Author's profile photo Former Member
      Former Member

      Hy Prabhu,

      please help. I already did all the steps and keep getting a 401 http.

      Do you know what it can be?

      In my example a ejb try to call a web service exposed by a bpm process as an intermediate message event.

      Regards,

      Filipe