on 07-17-2008 2:10 PM
Hello Experts!
I have written a JCO Server by using the Netweaver Developer Studio. Now I want to deploy this JCO Server on our SAP XI Server. The aim of this should be to create a connection between ABAP and JAVA to send data from JAVA to ABAP.
The RFC connection already exists and is working. What I don't know is how to deploy my JCO Server and how to start this JCO Server from our XI Server. I hope anybody could help me.
Thanks in advance!!!
Greetings Alexander
Here is the source code of my JCO Server:
public class JCOServer implements JCO.ServerExceptionListener, JCO.ServerStateChangedListener {
static public class Repository extends JCO.BasicRepository implements IRepository {
public Repository(String name)
{
super(name);
}
}
protected static IRepository repository;
static {
repository = new Repository("TestRepository");
JCO.MetaData fmeta = new JCO.MetaData("ZEJB_TEST_ZUGRIFF");
fmeta.addInfo("REQUTEXT", JCO.TYPE_CHAR, 255, 0, 0, JCO.IMPORT_PARAMETER, null);
fmeta.addInfo("ECHOTEXT", JCO.TYPE_CHAR, 255, 0, 0, JCO.EXPORT_PARAMETER, null);
fmeta.addInfo("RESPTEXT", JCO.TYPE_CHAR, 255, 0, 0, JCO.EXPORT_PARAMETER, null);
repository.addFunctionInterfaceToCache(fmeta);
}
static public class Server extends JCO.Server {
public Server(String gwhost, String gwserv, String progid, boolean isUnicode, IRepository repository)
{
super(gwhost,gwserv,progid,repository);
this.setProperty("jco.server.unicode", isUnicode?"1":"0");
}
protected void handleRequest(JCO.Function function)
{
JCO.ParameterList input = function.getImportParameterList();
JCO.ParameterList output = function.getExportParameterList();
JCO.ParameterList tables = function.getTableParameterList();
System.out.println("handleRequest(" + function.getName() + ")");
System.out.println("Anfrage vom SAP-Server: " + input.getString("REQUTEXT"));
if (function.getName().equals("ZEJB_TEST_ZUGRIFF")) {
output.setValue(input.getString("REQUTEXT"),"ECHOTEXT");
output.setValue("Das ist eine Antwort von JCOServer","RESPTEXT");
}
}
}
JCO.Server srv[] = new JCO.Server[1];
public JCOServer()
{
JCO.addServerExceptionListener(this);
JCO.addServerStateChangedListener(this);
}
public void startServers()
{
srv[0] = new Server("vxi1","sapgw00","BEAN",true,repository);
for (int i = 0; i < srv.length; i++) {
try {
srv.setTrace(true);
srv.start();
}
catch (Exception ex) {
System.out.println("Konnte Server nicht starten: " + srv.getProgID() + ":
" + ex);
}//try
}//for
}
public void serverExceptionOccurred(JCO.Server server, Exception ex)
{
System.out.println("Ausnahme in Server " + server.getProgID() + ":
" + ex);
ex.printStackTrace();
}
public void serverStateChangeOccurred(JCO.Server server, int old_state, int new_state)
{
System.out.print("Server " + server.getProgID() + " hat den Status geändert von [");
if ((old_state & JCO.STATE_STOPPED ) != 0) System.out.print(" GESTOPPT ");
if ((old_state & JCO.STATE_STARTED ) != 0) System.out.print(" GESTARTED ");
if ((old_state & JCO.STATE_LISTENING ) != 0) System.out.print(" HORCHEN ");
if ((old_state & JCO.STATE_TRANSACTION) != 0) System.out.print(" TRANSAKTION ");
if ((old_state & JCO.STATE_BUSY ) != 0) System.out.print(" BESCHÄFTIGT ");
System.out.print("] nach [");
if ((new_state & JCO.STATE_STOPPED ) != 0) System.out.print(" GESTOPPT ");
if ((new_state & JCO.STATE_STARTED ) != 0) System.out.print(" GESTARTED ");
if ((new_state & JCO.STATE_LISTENING ) != 0) System.out.print(" HORCHEN ");
if ((new_state & JCO.STATE_TRANSACTION) != 0) System.out.print(" TRANSAKTION ");
if ((new_state & JCO.STATE_BUSY ) != 0) System.out.print(" BESCHÄFTIGT ");
System.out.println("]");
}
public static void main(String[] argv)
{
JCOServer obj = new JCOServer();
obj.startServers();
}
}
Solved the problem!!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Alexander,
congratulations to the invention of the wheel....
Now, what do you think is the function of the application server itself? what you do here is to put a shell around JCO and then try to run it from another shell. Why not just use it from your program?
I recommend to do some of the examples with JCO and then see what the difference on this is.
Regards,
Benny
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Alexander,
I have to admit, that I did not know there is an actual server implementation for standalone use. Apologize for that. However, deploying this on a Java server is redoing the work that was already done, with less functionality. The J2EE community already defined the Java Resource Adapter standard for this.
Regards,
Benny
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.