Introduction

PI Web Services can be consumed in EJB similar to any other SOAP based web services. To have a secure way of execution of PI Web services in EJB, we can make use of service group component and provider system configured in SAP Enterprise Portal. These EJBs later can be consumed in any web based applications like WebDynpro JAVA, J2EE or SAPUI5 applications.

In this document, I have tried to explain the procedure of creating Service group component, mapping the PI SOAP web service to this service group. Configuring Provider system in SAP Enterprise portal and mapping the service group component to the Provider system, to have a secure way of execution of the PI web services.

Note: PI web services can also be created as RESTFul services. The procedure explained in this document is only for SOAP based services.

Step by Step Procedure

    • Create a new EJB module DC
      • Create an EJB DC

Switch to Development Infrastructureperspective -> right click on the SCA in Track (or LocalDevelopment -> MyComponents)-> New -> Development Component -> Java EE -> Select EJB Module and click Next. Enter the dc name and click on Finish.

EJB1.pngEJB2.pngEJB3.png

      • Add a 3.X Session Bean to the EJB DC

Switch to J2EE perspective -> right click on the EJB DC (created above) -> New-> Session Bean (EJB 3.X)-> Enter the package name and Class name and click Next and Finish.

EJB4.pngEJB5.png

      • Import the WSDL file into the EJB DC

Right click on the EJB DC -> Import -> import… -> Web Service -> select WSDL and click Next.

EJB6.pngEJB7.png

Select Remote Location/File System and click Next -> Enter the WSDL URL -> Click on Finish.

EJB8.pngEJB9.png

After the import, the WSDL files should be displayed in the project structure as shown in the below screen shot.

EJB10.png

    • Create a new Service Group Configuration DC

Switch to Development Infrastructure perspective -> right Click on the Track (or LocalDevelopment -> MyComponents) -> New -> Development Component -> Select Service Group Configuration and click Next. Enter the dc name and click on Finish.

SG1.pngSG2.png

    • Add the Service Group Configuration DC to dependencies list of EJB DC

Switch to J2EE perspective -> right click on the EJB DC -> Development Component -> Show In -> Component Properties. Open Dependencies tab, click on Add button. Search for the Service group Configuration DC created earlier and Select the DC and click on Next -> Finish.

    • Creating an EAR DC

Switch to Development Infrastructure perspective -> right Click on the Track (or LocalDevelopment -> MyComponents) -> New -> Development Component -> Java EE -> Select Enterprise Application and click Next -> Enter the DC name and
Click Next -> Next -> Select the EJB DC and Service group DC created earlier and click Finish.

EAR1.pngEAR2.png

EAR3.png

    • Creating the service reference for the WSDL file in EJB to the Service Group in Service Group Configuration DC

Switch to J2EE perspective -> right click on the WSDL file in EJB DC -> Web Services -> Create Service Reference.

Enter the Package name, Service Group Name, Service Group Description, and Select the Service Group Configuration DC created earlier, in the Create in Project dropdown and click Finish.

Repeat this procedure for all other WSDL files added to the EJB DC.

WSDL1.png

WSDL2.png

This will create the Service groups in the Service Group Configuration DC and will have the reference created between the new Service group and the WSDL as shown in the below screen shots.

Service Groups in Service Group Configuration DC.

WSDL3.png

Service group references in EJB DC

WSDL4.png

    • Creating the web service proxy for the WSDL files

Switch to J2EE perspective -> right click on the WSDL file in EJB DC -> Web Services -> Generate Client -> Click Next -> Select “Specify JAX-WS Customization files” and click Next  -> Finish.

Repeat this procedure for all the WSDL files added to the EJB DC.

WSDL5.png

WSDL6.png

WSDL7.png

At the end of this procedure, Java Client would have been created for each of the WSDL file under ejbModule folder in the EJB DC.

    • Creating the web service client application in the EJB DC

The Web service proxy generated in the previous step can be invoked from the EJB Session bean. Create a method in the Session bean and follow the below steps to invoke the web service proxy.

      • Retrieve an instance of the Web service proxy. In the below example, pernrLookupService is defined as instance variable of
        the EJB bean.

@WebServiceRef (name=“EmployeeLookupServiceService”)
EmployeeLookupServiceService
pernrLookupService;

      • In the method where the web service to be executed, retrieve an instance of the configuration port.

EmployeeLookupService pernrLookupServiceReq = pernrLookupService.getPort(EmployeeLookupService.class);

      • Set the input parameters to the configuration port.
      • Invoke the business method of the web service using the configuration port.

EmployeeSimpleByElementsRespMsg pernrResponse =

pernrLookupServiceReq.employeeSimpleByElementsQuery(empServiceReq);

Where EmployeeSimpleByElementsRespMsg is a response class and empServiceReq is the request data to be passed to
the web service.

Build and Deploy the EAR DC.

    • Configuration of Provider System in SAP Enterprise Portal

Login to NWA and navigate to SOA -> Technical Configuration -> System Connections -> Provider Systems.

PS1.png

Click on Newbutton to create a new Provider System.

PS2.png

Enter the System name, select System type as “Other”, provide the description and click on Next.

PS3.png

Click on Switch to Advance Mode link, as highlighted in the below screen and provide the WSDL or WSIL URL. Also enter the Authentication settings and click Next.

Three types of runtime authentication is possible.

      • SSO using SAP Logon Ticket/ No Authentication
      • Technical User (Providing Technical User Id and Password)
      • User Accounts (User account setup in SOA manager with user id/password configured)

PS4.png

Check Do Not Use RFC Connectivity checkbox and click Next.

PS5.png

Verify the message and click Finish.

PS6.png

    • Map Provider system to Service Groups

To map the provider system configured in SAP Enterprise portal with the Service groups deployed as part of Service configuration DC created earlier, follow the below steps.

Login to NWA and navigate to SOA -> Application and Business Scenario Communication -> Application Communication.

SG_PS1.png

Search for the Service Group Configuration component, deployed on the server.

SG_PS2.png

Select the Service group configuration component and click on Edit button in the Consumed Service Groups tab.

Select the provider system(s) created earlier from the drop down in Provider Systems column and click on Save button to save the changes.

SG_PS4.png

    • Setting the Service Endpoint Port mapped to Provider System as default Port

Login to NWA -> SOA -> Single Service Administration.

PORT1.png

Switch to Consumer Proxies tab and search for the Service endpoint by its name. We should get two endpoints for each web service, as shown below. One endpoint is the representation of mapping between service group and Provider system and the other, for the service used in the EJB component.

PORT2.png

Select the second endpoint and select the port defining the mapping between Service group and provider system as shown in the below screen and click on Set as Default button.

PORT3.png

Conclusion

By following the above mentioned procedure, one can achieve a secure execution of PI web service from an EJB. The EJB then can be consumed in a WDJ, Java/J2EE and SAPUI5 applications or in a BPM process step.

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

  1. Rami Reddy

    Hi  Vishweshwara,

    Thanks for providing the valuable consuming PI webservice in EJB DC.

    I have also similar kind of requirement. I want to pass the input values to PI WebService and execute the PI WebService from EJB DC.

    So above mentioned steps should match my scenario right. But here I didn’t see any where to set the values PI WebService.

    Request for confirm.

    Regards,

    Ramireddy

    (0) 
    1. Sankar Kalapatapu

      HI Ramireddy,

      we require same code what you have requested. Could you please let me know to call the web service methods in the code. In the last step after creation of web service application in the client DC step I.e. Before provider system step. We would require info of how to call. Could you please let us know the clear steps in order to proceed further.

      THank’s,

      sankar.

      ,

      (0) 

Leave a Reply