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
0 Kudos

I came accross a requirement in one of my assignment, in which I was expected to write a Web Service to fetch the data from MDM tables. I thought to share the steps I followed to acheive this requirement through this blog.


Requirement: Implement a webservice to fetch data from MDM tables.

Solution:

Step 1: Create a EJBProject

Step 2: Create a Session Bean in the EJB project created in previous step. To do so, right click on the EJBModule and select Session bean from the menu.

Give package name, Bean class name and check the "Remote" check box. Once done, Click on finish button.

We have successfully created a Session bean.

Step 3: Add below dependencies to the EJB project. These are required to use MDM APIs.

Step 4: Create an "Enterprise Application" project and add the EJB project created in Step1 in the Java EE dependency screen, click on finish.

At this point, all required projects and dependencies are created.

Step 5: Create a SYSTEM_USER in MDM repository which we require to connect to MDM system.

Step 6: Open the Session bean created previously and declare a method in it. Add the below code to connect to MDM in the Session bean class.

Step 7: We successfully connected to MDM repository in the above step. Now we have to query the MDM table to fetch the desired record.

My requirement was to query "Sites" table based on "Country" and "Organization" which are provided as input to web service.

Below is the code I used to fetch the records . This piece of code can be modified based on individual requirement.

 

Step 8: Loop through the Result Set and set the required output fields to return variable of our method, which will be output from web service.

Step 9 : Copy the method signature the we created in Session bean and paste it in the "Remote" interface class created. This is required to create Our Web Service.

Step 10: Let's expose our Session bean as Web Service. To do so, right click on the Session bean --> Web service --> Create Web Service.

Check the "Publish the Web serice" check box and click next. In the following screen, select "create New Interface" option  and give a name to Interface.

Select the method to be exposed in the Web Service and click on finish button. Now we have successfully created a web service out of our Bean.

Step 11: Build the Enterprise application project and deploy on the server.

Step 12: We have successfully deployed our changes on server. Now let's login to WSnavigator to test the web service.

Step 13: Provide username and password and log into wsnavigator. Select Provider system radio button and enter the service name and click on search button. we will get the list of service available in the Service. Select our service and click on Next button.

Step 14: Provide the necessary inputs and click on next button. If the matching record is found, We we get the desired output.

I Hope this will be usefull.

Regards,

Pavan

Labels in this area