This Wiki is helpful for those who want to work with java proxies. It contains the breif description of proxies and prerequisites and step-by-step approach to implement Outbound Java proxies along with Inbound ABAP proxy.
SAP proxy model enables to differentiate Integration logic from the Application logic, proxies are outside-in development approach where we can generate executable interface from non-language specific code (like WSDL). In SAP Exchange Infrastructure environment using proxy runtime application system (Business System) can send and receive messages from/to the Integration Server.
SAP provide two approaches to implement proxies
1. ABAP Proxies
2. Java Proxies
WAS 6.20 with xi2.0 add-on is the minimum configuration to support ABAP proxies, updating to WAS 6.40 need regeneration of all the proxy objects generated on previous versions.
SAP J2EE Engine 6.40 with Service Pack SP5 or higher needed to work with proxies, along with this installing Java Proxy Runtime (JPR) and Messaging Service (MS), which provides services like messaging, queuing, and persistency of XI messages.
The following figure illustrates the scenario synchronous java proxy as outbound which sends Sales Document Number request message to Integration Server using Messaging Service and ABAP proxy as synchronous inbound, which receives the request message from Integration Server and the ABAP proxy runtime processes and send the response.
Before proceed to the actual procedure we assume that the configuration steps between R/3 and PI are done successfully.
In Exchange Infrastructure's Repository we need to create the following objects.
2. Data Type
3. Message Type
4. Message Interface
5. Mapping Program
6. Mapping Interface
1. Implementing the Inbound ABAP Proxy
In Receiver R/3 system go to transaction SPROXY and select the inbound interface and create server proxy, this will generate Interface and implementing class, along with this structure objects and table type.
You can view the structure of the method EXECUTE_SYNCHRONOUS in the interface generated.
In order to implement the method in interface, click on the implementation class by forward navigation it will direct to the class builder, you can see the method to implement in the methods tab.
Implement the method by adding business functionality, the following is the implementation code.
method zii_mi_s_in_sales_document_yh1~execute_synchronous. types: beginof type_sales_doc_res,
document_no type vbak-vbeln,
document_dt type vbak-erdat,
author_name type vbak-ernam,
doc_category type vbak-vbtyp,
doc_type type vbak-auart,
dev_blk type vbak-lifsk,
bill_blk type vbak-faksk,
netval type vbak-netwr,
sals_org type vbak-vkorg,
sold_party type vbak-kunnr, endof type_sales_doc_res.
fs_sales type type_sales_doc_res,
itab_sales like tableof
fs_sales. data :
fs_out_res type zdt_sales_doc_res_details.
kunnr from vbak intotable itab_sales where vbeln = input-mt_sales_doc_req-document_no. loopat itab_sales into fs_sales. move-corresponding fs_sales to fs_out_res. append fs_out_res tooutput-mt_sales_doc_res-details. endloop. endmethod.
In order to test this server proxy functionality go to SPROXY transaction and select the Test Interface icon from toolbar as show in following figure.
2. Testing the Inbound ABAP Proxy
This will display the sender payload; you can edit the pay load and change the request parameter value and execute.
The resulting payload after service is the response from the inbound server proxy, you can see it in the following figure.
3. Generating Outbound JAVA Proxy
Now the inbound server proxy (ABAP) is working fine, now we need to generate outbound client java proxy. In Integration Repository select the Outbound Message Interface and right click on it select the option Java Proxy Generation from the context menu.
This display the wizard to generate the java proxy libraries, there are 4 steps involved in generating java proxy jar file.
Select the location of the .jar file and provide the file name
Select your Software Component Version
Select respective outbound interface.
Check the selected data in the wizard as final step.
Once the jar file generation is finished, you need to import that into your NWDS EJB project.
4. Implementing Outbound JAVA Proxy
Create new EJB Module Project, and then import the .jar file in your project.
Select the Zipfile option and specify the project folder location. The bean class and local, home, remote interfaces are unzipped into project folder. Right click on ejb-jar.xml and select add EJBs from context menu and select the Bean class.
The source of ejb-jar.xml is generated from the selected bean class and shows as follows,You can directly change the source by adding the entries manually.
Once the addition of bean class to ejb-jar.xml, we need to implement the application in the same package along with the generated EJB bean interfaces. The following is the implementing client java proxy code.
The following libraries are required in order to compile generated bean class and interfaces.
Once the client implementation code is finished, start building the project, this creates EJB Archive jar file. Once finished the creation of EJB archive, you can call it from jsps.
5. Calling Client JAVA Proxy in JSPs and Deploying EAR
To call client java proxy in to JSP page requires creation of new Web Module Project and add the EJB Module project as a reference project. Then implement the jsp by calling the method of the client proxy implementation class. Once building of Web Module Project is done, create Enterprise Application Archive project and add the EJB Module and Web Module projects as reference projects.
Once we add the two referenced projects the application.xml displays these projects as show below. Add the references of libraries in application-j2ee-engine.xml file as shown in following figure. The proxy libraries shall not be included in the Archive while deploying.
Once adding the reference libraries to application-j2ee-engine.xml build the project and deploy the .EAR in J2EE engine using SDM (Software Deployment Manager).