Step-by-step guide to use Java and ABAP Proxies in a scenario

...Previous

This display the wizard to generate the java proxy libraries, there are 4 steps involved in generating java proxy jar file.  

  1. Select the location of the .jar file and provide the file name
  2. Select  your Software Component Version
  3. Select respective outbound interface.
  4. Check the selected data in the wizard as final step.

Once the jar file generation is finished, you need to import .jar into your NWDS EJB project.  

4. Implementing Outbound JAVA Proxy  

Create new EJB Module Project, and then import the generated  jar file in your project.

 

Select the Zip file 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 libraries are required in order to compile generated bean class and interfaces.  

            aii_proxy_xirt.jar

            aii_msg_runtime.jar

            aii_utilxi_misc.jar

            guidgenerator.jar  

Add the above list of jars to the project and then implement the class, which access the proxy bean and access the request and response methods. In this class we need to set the request variable and get the response and return as shown below code snippet.  

MISOUTSlaesDocumentYH1302_PortTypeHome queryOutHome = null;
MISOUTSlaesDocumentYH1302_PortTypeRemote queryOutRemote = null;
try {
	InitialContext ctx = new InitialContext();
	Object ob =	ctx.lookup(					"java:comp/env/ejb/MISOUTSlaesDocumentYH1302_PortTypeBean");
	queryOutHome =(			MISOUTSlaesDocumentYH1302_PortTypeHome) PortableRemoteObject
						.narrow(ob,
			MISOUTSlaesDocumentYH1302_PortTypeHome.class);
	queryOutRemote = queryOutHome.create();
	role = role + "Ready";
	MessageSpecifier msg = queryOutRemote.$messageSpecifier();
	msg.setSenderService("BS_PI9_JAVA");
	queryOutRemote.$messageSpecifier(msg);
	role = role + "Service Called";
	DTSalesDocReq_Type reqtype = new DTSalesDocReq_Type();
	document_no = doc_num;
	reqtype.setDocumentNo(document_no);
	role = role + "Request Sent";
	DTSalesDocRes_Type response = new DTSalesDocRes_Type();
	response = queryOutRemote.mISOUTSlaesDocumentYH1302(reqtype);
	DTSalesDocRes_Type.Details_Type[] sales_dets =
	response.getDetails();
	for (int i = 0; i < sales_dets.length; i++) {
		role = role + sales_dets[i];
	}
} catch (NamingException nex) {
	role = role + nex.getMessage();
} catch (CreateException cex) {
	role = role + cex.getMessage();
} catch (Exception ex) {
	role = role + ex.getMessage();
}

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).

 

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image