In my work integrating apps, I usually find the scenario where I need to consume a BAPI or RFC function in an HTTP way. Publishing HTTP ports from core ABAP application server to Internet frequently have security restrictions and installing and configuring a big middleware can be a long term task. You can use this simple connector based in Tomcat and JCO for development of your prototype applications accesing services of an SAP NetWeaver backend.
1) Download and Install JAVA JDK.
http://java.sun.com/javase/downloads/index.jsp (http://java.sun.com/javase/downloads/index.jsp)
2) Download and Install Tomcat.
http://tomcat.apache.org/download-60.cgi3) Set environment variables:4) Copy JCO files ( sapjco.jar, sapjcorfc.dll and librfc32.dll ) into Note: JCO ( SAP Java Connector ) come inside your SAP NetWeaver Composition Environment (
http://www.sdn.sap.com/irj/sdn/downloads?rid=/webcontent/uuid/600563cb-c341-2a10-8982-dbfe1a2d100c ) or you can get it from SAP Marketplace ( https://service.sap.com/connectors/ (https://service.sap.com/connectors/) ) , loggin required.
5) Create "connector" (or name you prefer) directory inside your 6) put these pages inside.
controller.jsp<br /><textarea cols="90" rows="20"><jsp:directive.page import="com.sap.mw.jco.*" />
<jsp:directive.page import="java.io.StringWriter" />
<%
String airline = "";
String result = "";
try {
JCO.Client mConnection;
JCO.Repository mRepository;
JCO.Function mFunction;
JCO.Table mTable;
mConnection =
JCO.createClient( request.getParameter ("sap-client") , // SAP client
request.getParameter("sap-user") , // userid
request.getParameter("sap-password") , // password
request.getParameter("sap-language") , // language
request.getParameter("sap-host") , // application server host name
request.getParameter("sap-system") ); // system number
mConnection.connect();
mRepository = new JCO.Repository("myRep", mConnection);
mFunction = mRepository.getFunctionTemplate( request.getParameter("sap-rfc") ).getFunction();
int n = Integer.parseInt( request.getParameter("sap-totalparam") ) ;
for ( int i=0; i<n; ++i ) {
mFunction.getImportParameterList().setValue( request.getParameter( "sap-value" + String.valueOf(i+1) ) , request.getParameter( "sap-param" + String.valueOf(i+1) ) );
}
mConnection.execute(mFunction);
mTable = mFunction.getTableParameterList().getTable( request.getParameter("sap-table") );
StringWriter writer = new StringWriter();
mTable.writeXML(writer);
result = writer.getBuffer().toString();
mConnection.disconnect();
}
catch (Exception ex) {
result = ex.getMessage();
}
out.print(result);
%>
</textarea></p><p>view.html
sap-client:
sap-user:
sap-password:
sap-language:
sap-host:
sap-system:
sap-rfc:
sap-totalparam:
sap-param1:
sap-value1:
sap-param2:
sap-value2:
sap-tableout:
7) Startup Tomcat.
8) Test your http/rfc call
http://localhost:8080/connector/view.html (http://localhost:8080/connector/view.html)
!https://weblogs.sdn.sap.com/weblogs/images/251678771/connector.PNG|height=400|alt=|width=533|src=htt...!</body>