Blogs

Abdelmorhit El Rhazi

How to Consume an Inbound Backend Web Service in NWDS/Jboss environment
Abdelmorhit El Rhazi SAP Employee
Business Card
Company: SAP Labs Canada
Posted on Oct. 30, 2009 12:40 PM in Eclipse, Enterprise Service Community, Java Programming, Service-Oriented Architecture

Subscribe.Subscribe
Print. Print
Permalink Permalink

SAP systems are providing enterprise web services to ease the integration between different backend systems (SAP or non SAP systems). These web services could be categorized into two categories: Inbound web services and outbound web services. An outbound operation is used by a caller application to send a request message. An inbound operation implements a service that is to be called by an application[1].

This document shows a way to consume an inbound web service provided by an SAP ERP system by an application running in Jboss application server. The scenario consists on getting the WSDL of a Merchandise Category service, generates the web service client and deploys an EJB project in Jboss.

Prerequisites:

To be able to execute these steps, the following prerequisites have to be taken into consideration:

  1. Netweaver Developer Studio (NWDS) is installed and configured ;
  2. Jboss is installed and configured ;
  3. A user in the backend system is available.

Execution Steps:

1-      Get the WSDL of the service from the backend system.

a.       Connect to the backend system

b.      Run SOAMANAGER transaction, a new browser will start

c.       Select Application and Scenario Communication -> Single Service Administration

d.      Search for the service (e.g. MerchandiseCategorySimpleByIDAndDescriptionQueryResponse_In)

e.       Select the service name and hit Apply Selection

f.       If there is no binding for the service, you have to create a new service/binding for it. In this case, select Configuration tab and hit Create Service and fill the mandatory fields by a new service name and binding name

g.      Keep the default values and check the UserId/Password in Transport Channel Authentication

h.      Hit Save button to save the new service/binding

i.        Now, in the Overview tab, you will be able to get the wsdl of your service. The new binding will be shown in the dropdown list. Select this binding and hit the link “Open WSDL document for selected binding”

j.        A browser will open with the wsdl of the service. Save the xml content as an WSDL file in your local machine.

k.      As result, you have the wsdl of your service with all the binding needed to run the service remotely.

 2-      Configure your Jboss in NWDS

a.       Open your NWDS

b.      If the “Servers” view is not shown, select Window->Show View->Other->Server->Servers

c.       In the Servers view, right click and select New->Server

d.      In the New Server wizard, Select Jboss-> Jboss v4.2 (or your version of JBoss)

e.       Select your JRE and browse to the folder where you have installed your JBoss

f.       Keep the default values and click finish

g.                  As result, the JBOSS 4.2 is created in the view in stopped mode. To run the server, select the server and right click, then hit Start command.

 3-      Create the Web Service Proxy in NWDS

a.       Create an EJB project : File->New->Project

b.      In the wizard, select EJB->EJB Project

c.       Enter the new name of the project and select for the Target Runtime : JBoss v4.2 and for the Configurations the default one for JBoss

d.      Enter the name of the new ear project. The creation values are shown in Figure 1.

EJB Project Creation

Figure 1 New EJB project creation

 

e.       Hit the new button to configure the creation of the ear project. Keep the default value for all the steps, except for the last step, check the Generate Deployment Descriptor checkbox. Hit finish button to create the ear project.

f.       Continue creating the EJB  project by hitting Next button, keep the default values, except for the last step, check the Generate Deployment Descriptor checkbox. Hit finish button to create the EJB project.

g.      As result the EJB project, EAR project are created.

h.      Import the wsdl of the service, created in the first phase, into your EJB project

i.        Select the EJB project, right click, then select Import-> Import->Web Services->WSDL. The wizard of the wsdl import will start.

j.        Select the Remote Location / File System and browse to the wsdl file of the service

k.      When imported, the wsdl file is validated. Open the wsdl file to check the errors.

If you get the following error: '<Your service>_In' port type specified for the '<Your Service Binding>' binding is undefined.  Delete the policy tag wsp:Policy under the tag wsdl:portType and under the tag wsdl:binding.

 

l.        To generate the Proxy client for the service, right click on the wsdl imported, then select Web Wervices-> Generate Client

m.    Keep the default values for the wizard steps, except for the following steps:

n.      Select Develop Client, Server : Jboss, Web Runtime:SAPNetweaver 

Web  Service client generation

Figure 2 Web Service  Proxy creation

 

o.      Select all the generation checkbox except for the interfaces, if you want to use the session beans, which will consume your service, as web service.

Web Service Client generation

Figure 3 Web Service Proxy Creation

 

p.      As result, your EJB project contains all artifacts for the web service proxy client

 4-      Usage of the web service Proxy by a Session Bean

a.       Create a new Session Bean within your EJB project

b.      Select your project, right click, select New->Other->EJB->EJB3 Session Bean

c.       Enter the name of your new Session Bean and its package

d.      Implement your Session Bean

e.       Make a reference to your web service by specifying a unique name and wsdl location

 

f.       Get an instance of the port type      

inboundCode2

g.      Set the user/password for calling the backend service(if needed)

 

inboundCode3

 

         

h.      Call the service operation with your parameters

inboundCode4

i.         As result, your have created a Session Bean that calls the backend web service. The following listing contains an example of session bean that has one operation that calls the backend web services and returns the results. To test your session bean, you can generate a web service out of it and tested using saopUI freeware tools.

                    

inboundCode6

j.        To deploy your web service proxy and session bean, right click on your JBoss server in the Servers view, and click on Add Remove Projects, add you ear file and click finish.

k.       If you have generated a web service using the session bean, you could check the deployed services using (http://localhost:8080/jbossws/services)

l.        In case you want to test your web service, you might use SAOPUI tool which could be download from (http://www.soapui.org/)

      

Abdelmorhit El Rhazi (Eng. PhD.) is a senior software developer in SAP Trade Engineering team in Montréal.


Add to: del.icio.us | Digg | Reddit


Comment on this article
Comment on this weblog