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
3. Switch to Service Composer Perspective. Create a new Service Group under Connectivity
4. In this scenario, I am creating a non-classified Service Group
5. Open the newly created Service Group to view details
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
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
3. Click on Edit button and choose create from provider system as shown below
4. It shows create screen as below, select required system name, system type to assign provider system
5. Once service group is configured with provider system it shows green status as below
How to invoke web service from EJB:
1. Right click on working DC, Import > WSDL and Open Import wsdl dialogue from NWDS
2. Choose Remote Location / File System as below
3. Give wsdl url and click on finish button
4. Now wsdl file is downloaded in to the DC
5. Right-click on wsdl file and Web services > Create Service Reference as below
6. In the New Service Reference dialogue choose existing service group that was already configured in the previous step explained before.
7. After click on Finish button newly added service reference is appeared as below
8. Now from the EJB call the web service as below
(a) Add local variable in EJB as below:
(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.
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
3. Click on Next and give connectivity type and metadata user/pass to invoke web service
4. Go to assignment tab and click on new and choose “Test” user that was created earlier in the previous step
5. Now click on Next button and choose provider system
6. Now newly created User account is showing provider system and service group as below
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.