Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

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.

      • 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.

      • Import the WSDL file into the EJB DC

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

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

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

    • 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.

    • 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.

    • 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.

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.

Service group references in EJB DC

    • 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.

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.

Click on Newbutton to create a new Provider System.

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

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)

Check Do Not Use RFC Connectivity checkbox and click Next.

Verify the message and click Finish.

    • 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.

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

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.

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

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

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.

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.

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.

2 Comments
Labels in this area