1. This document describes a Java client proxy scenario using SAP NetWeaver Process Integration (PI) 7.0 to forward a request from a JSP page to a database and return the response.
2. The key steps include developing Java classes and JSP pages, generating Java proxies, configuring sender and receiver agreements in PI, and deploying an Enterprise Application to the SAP J2EE engine.
3. The process involves sending a request from a JSP containing a username and transaction, forwarding it to the database via PI, and returning the corresponding data to the original JSP page as the response.
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
143 views
Java Client Proxy Scenario in PIXI
1. This document describes a Java client proxy scenario using SAP NetWeaver Process Integration (PI) 7.0 to forward a request from a JSP page to a database and return the response.
2. The key steps include developing Java classes and JSP pages, generating Java proxies, configuring sender and receiver agreements in PI, and deploying an Enterprise Application to the SAP J2EE engine.
3. The process involves sending a request from a JSP containing a username and transaction, forwarding it to the database via PI, and returning the corresponding data to the original JSP page as the response.
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10
Java client proxy scenario in PI/XI
By Rachit Sehgal, CSC India
Scenario Introduction In this article we explore a business scenario that involves sending a request from a JSP page to SAP NW PI 7.0, which forwards the request to a database and fetches the response. The request contains the username and transaction and the corresponding data is returned to JSP as response. Logical Flow of the Business Scenario 1. Request is sent from a JSP page. 2. The request invokes a Java application class (developed by user for proxy invocation) that is deployed along with the EAR project (which includes the generated proxy beans/classes) in the SAP J2EE Engine. 3. The Java application class performs a lookup for the required client bean in the SAP J2EE Engine and sends the request data. 4. This client bean uses the generated proxy classes and forwards the message to Java Proxy Runtime. 5. The Java Proxy Runtime of the J2EE Engine forwards the request to the messaging system. 6. The messaging system forwards the request to the Integration Server of SAP Exchange Infrastructure using the HTTP URLhttp://<server>:<ABAP-http port>/sap/xi/engine?type=entry 7. Configuration steps like sender agreement, receiver determination, interface determination, and interface mapping are performed. 8. The message is routed to the Adapter Framework using HTTP URLhttp://<server>:<J2EE- http port>/MessagingSystem/receive/AFW/XI 9. In the Adapter Engine the channels and agreements are read and then the respective communication channel using the JDBC adapter (in this business scenario) forwards the request message to the receiver database. 10. Response is routed back to the sender Java application after the steps like interface mapping (response message mapping). 11. The Java application routes the response to the JSP page that initiated the request Development Steps Integration Builder Design Time 1. Define Data Types, Messages Type for the following Message Mappings Request Message Mapping -- JDBC_Select_File_Req_To_JDBC_Req_MM_HTTP Response Message Mapping -- JDBC_Select_JDBC_Res_To_JDBC_Res_HTTP Request Message Mapping
Response Message Mapping
2. Interface Mapping
3. Generating the Java Proxies for the Outbound Message Interface Generate the Java proxies using Java Proxy Generation, select the outbound message interface. (User_Sync_MI_HTTP)
Generated Classes and Beans
Integration Builder Configuration Time Sender Agreement: Create a sender agreement Receiver Determination: Create the receiver determination using the database business system. Interface Determination & Mapping: Create the interface determination and the interface mapping using the mapping of design time. Receiver Agreement: Create the receiver agreement using the JDBC adapter communication channel. Create an EJB Module Project Using NW Developer Studio <ejb-jar> <description>EJB JAR description</description> <display-name>EJB JAR</display-name> <enterprise-beans> <session> <ejb-name>UserSyncMIHTTP_PortTypeBean</ejb-name> <home>psharma51Testarea.UserSyncMIHTTP_PortTypeHome</home> <remote>psharma51Testarea.UserSyncMIHTTP_PortTypeRemote</remote> <local- home>psharma51Testarea.UserSyncMIHTTP_PortTypeLocalHome</local-home> <local>psharma51Testarea.UserSyncMIHTTP_PortTypeLocal</local> <ejb-class>psharma51Testarea.UserSyncMIHTTP_PortTypeBean</ejb- class> <session-type>Stateless</session-type> <transaction-type>Container</transaction-type> </session> </enterprise-beans> </ejb-jar> Here psharma51Testarea is actually the namespace in the design time where message interfaces have been developed. In the EJB project it (psharma51Testarea) is the package that includes all the classes that are generated. Along with generated classes, a Java class needs to be developed that will invoke this proxy bean. This application class can be included in the same EJB project. JNDI Name <ejb-j2ee-engine> <enterprise-beans> <enterprise-bean> <ejb-name>UserSyncMIHTTP_PortTypeBean</ejb-name> <jndi-name>JavaProxy</jndi-name> <session-props/> </enterprise-bean> </enterprise-beans> </ejb-j2ee-engine> Finally, create the Java archive of the EJB module project. Java Class ProxyCall package psharma51Testarea; import java.util.*; import javax.naming.*; import javax.rmi.*; import com.sap.aii.proxy.xiruntime.core.MessageSpecifier; public class ProxyCall {
String str = "";
JDBCSelectFileTrgDTHTTP_Type response;
UserSyncMIHTTP_PortTypeHome queryOutHome; UserSyncMIHTTP_PortTypeRemote queryOutRemote; ArrayList abc = new ArrayList();
public JDBCSelectFileTrgDTHTTP_Type getResult(String material) { try{ Context ctx = null; Properties p = new Properties();
// Cast to Home interface queryOutHome = (UserSyncMIHTTP_PortTypeHome)PortableRemoteObject.narrow(ref,UserSyncMIHTTP _PortTypeHome.class);
// Get Remote interface queryOutRemote = queryOutHome.create(); str=str+"c";
JDBCSelectFileSrcDTHTTP_Type reqtype = new JDBCSelectFileSrcDTHTTP_Type(); reqtype.setBNAME("Rac"); // TP Name reqtype.setOPERATION("EQ"); // Transaction
str=str+"d";
//Call the Java proxy and get the return parameters //initialise the Message Specifier //queryOutRemote.$messageSpecifier(); MessageSpecifier msg = queryOutRemote.$messageSpecifier(); str=str+"e123"; msg.setSenderService("JavaProxy_BS"); queryOutRemote.$messageSpecifier(msg); str=str+"f333";
JDBCSelectFileTrgDTHTTP_Type.ROW_List b = new JDBCSelectFileTrgDTHTTP_Type.ROW_List(); b = response.get_as_listROW();
int i = b.size(); String a = ""; ArrayList l = new ArrayList();
for (int j=0; j<i; j++) { JDBCSelectFileTrgDTHTTP_Type.ROW_Type c = b.getROW(j); a = c.getBNAME(); l.add(a); }
return l; } } Create a Web Module Project Create a web module project (ProxyWeb). Create 2 JSP pages UserClient jsp page sends username and transaction and UserDisplay jsp page displays the corresponding name as response. Finally, create the web archive (WAR) for the above project. UserDisplay jsp <HTML> <%@ page language="java" import="psharma51Testarea.*"%> <jsp:useBean id="user" class="psharma51Testarea.testing" scope="session"/> <jsp:setProperty name="user" property="*"/> <BODY> <% JDBCSelectFileTrgDTHTTP_Type resp = user.getResult("ABC"); ArrayList value = user.getName(); for (int i=0; i< value.size(); i++) { String name = (String)value.get(i); } %> </BODY> </HTML> web.xml <web-app> <display-name>WEB APP</display-name> <description>WEB APP description</description> <servlet> <servlet-name>UserDisplay.jsp</servlet-name> <jsp-file>/UserDisplay.jsp</jsp-file> </servlet> </web-app> Create the war file of the above Web Module Project Create an Enterprise Application Project Create an Enterprise Application project (ProxyEAR) add the above EJB and web module projects to this EAR. The following dependencies must be declared in the application-j2ee-engine.xml <application-j2ee-engine> <reference reference-type="weak"> <reference-target provider-name="sap.com" target-type="library">com.sap.aii.proxy.xiruntime </reference-target> </reference> <reference reference-type="weak"> <reference-target provider-name="sap.com" target-type="library">com.sap.aii.messaging.runtime </reference-target> </reference> <reference reference-type="weak"> <reference-target provider-name="sap.com" target-type="library">com.sap.xi.util.misc </reference-target> </reference> <reference reference-type="weak"> <reference-target provider-name="sap.com" target-type="library">com.sap.guid </reference-target> </reference> <provider-name>sap.com</provider-name> <fail-over-enable mode="disable"/> </application-j2ee-engine> Finally, deploy the EAR file into the SAP J2EE engine. Test the scenario by invoking the JSP page. Give the user name and transaction and it should return the corresponding data as its response.