Skip to Content

In part-1 we created table in java dictionary and deployed it on SAP PI server. And we also created Entity bean class for the table. Next we have to create EAR project for the EJB entity bean and create session bean to access entity bean and deploy it in the java server.

STEP 3: Create EAR project for the entity bean project.

Select File > New > Other

/wp-content/uploads/2016/01/2_a_869904.jpeg

Select Development Infrastructure > Development Component and click Next

/wp-content/uploads/2016/01/2_b_869905.jpg

Select Java EE > Enterprise Application and click Next

/wp-content/uploads/2016/01/3_b_869909.jpg

Select MyComponents and click Next

/wp-content/uploads/2016/01/2_d_869910.jpg

Provide Development Component Name and click Next

/wp-content/uploads/2016/01/3_c_869911.jpg

Select the EJB project and click Finish

/wp-content/uploads/2016/01/3_d_869915.jpg


STEP 4: Create JDBC DataSource Alias


Open SAP PI NWA and navigate to Configuration > Infrastructure > Application Resource and create new JDBC DataSource Alias

/wp-content/uploads/2016/01/4_a_869916.jpg

Provide DataSource Alias Name and Select DataSource Name (In format SAP<SID>DB) and click save

/wp-content/uploads/2016/01/4_b_869924.jpg


STEP 5: Create DataSource Descriptor for EAR project


Right click the EAR project and select properties

/wp-content/uploads/2016/01/5_a_869925.jpg

Select Project Facets and check SAP Data Source Aliases Provider Module and click OK

/wp-content/uploads/2016/01/5_b_869926.jpg

In project explorer Expand the EAR project and navigate to META-INF and double click on data-source-aliases.xml

/wp-content/uploads/2016/01/5_c_869930.jpg

Select General tab and expand to Aliases > ${com.sap.datasource.default} and give the DataSource Alias name created in previous step and save it.

/wp-content/uploads/2016/01/5_d_869931.jpg


STEP 6: Create Session Bean to Access Entity Bean


For the session bean to access the entity bean, we must create persistence descriptor in EJB project to identify datasource


Right click on EJB project and select properties. Click on project Facets and check Java Persistence and click OK

/wp-content/uploads/2016/01/6_a_869932.jpg

In project explorer, Expand the EJB project > ejbModule > META-INF and open persistence.xml in XML editor and add jta-data-source to persistence-unit

/wp-content/uploads/2016/01/6_b_869942.jpg

Provide Persistence-unit name and enter the datasource alias name created previously

/wp-content/uploads/2016/01/6_c_869943.jpg

Right click on EJB project and Select New > Session Bean

/wp-content/uploads/2016/01/6_d_869945.jpg

Enter package, class name and check Local business interface and provide local interface name and click Finish

/wp-content/uploads/2016/01/6_e_869940.jpg

Add @Webservice and @PersistenceContext annotations in the session bean

/wp-content/uploads/2016/01/6_f_869941.jpg

Add methods to create, read, update and delete rows in the table in the session bean

Create method:

/wp-content/uploads/2016/01/6_g_869960.jpg

Read method:

/wp-content/uploads/2016/01/6_h_869961.jpg

Update method:

/wp-content/uploads/2016/01/6_i_869962.jpg

Delete method:

/wp-content/uploads/2016/01/6_j_869966.jpg

Get all rows in the table:

/wp-content/uploads/2016/01/6_k_869967.jpg

Add the methods to the local interface to expose the methods to local clients. Right click on method and Select EJB Methods > Add to Local Interfaces

/wp-content/uploads/2016/01/6_l_869968.jpg

Local interface should look this

/wp-content/uploads/2016/01/6_m_869969.jpg

Right click on EJB project and Select Development Component > Build

/wp-content/uploads/2016/01/6_n_869970.jpg

Right click on EAR project and Select Development Component > Deploy

/wp-content/uploads/2016/01/6_o_869972.jpg

Deployment should be successful without errors


STEP 7: Add authentication to the webserivce deployed


Open NWA in SAP PI and navigate to SOA > Application and Scenario Communication > Single service administration and search for the service deployed

/wp-content/uploads/2016/01/7_a_869973.jpg

Select Configuration tab below and select the endpoint and click edit button below it

/wp-content/uploads/2016/01/7_b_869974.jpg

Select Security tab and check  User ID/Password in HTTP authentication and save it

/wp-content/uploads/2016/01/7_c_869978.jpg

Next steps are covered in Part 3


To report this post you need to login first.

Be the first to leave a comment

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

Leave a Reply