on 04-30-2008 3:30 PM
Hello,
I'm trying to create a RFC Server in Java. I tried the example code and it works certain times and the fails...
package com.sap.coe.h2o.rfc.server;
import com.sap.mw.jco.IRepository;
import com.sap.mw.jco.JCO;
public class H2ORfcServer extends JCO.Server {
/**
* Create an instance of my own server
*
* @param gwhost
* (gateway host)
* @param gwserv
* (gateway service number)
* @param progid
* (program id)
* @param repository
* (repository used by the server to lookup the definitions
* of an inc)
*/
public H2ORfcServer(String gwhost, String gwserv,
String progid, IRepository repository) {
super(gwhost,gwserv,progid,repository);
}
/**
*
* Overrides the default method.
*
*/
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() + ")");
if (function.getName().equals("STFC_CONNECTION")) {
System.out.println(">>> request STFC_CONNECTION: " + input.getValue("REQUTEXT"));
output.setValue(input.getString("REQUTEXT"),"ECHOTEXT");
output.setValue("This is a response from MyFirstServer","RESPTEXT");
}
}
}
I create THREE instances of my server with:
package com.sap.coe.h2o.rfc.server;
import com.sap.mw.jco.IRepository;
import com.sap.mw.jco.JCO;
public class StartRFCServer {
static H2ORfcServer serverConnections[] = new H2ORfcServer[3];
/**
*
* Start the server
*
*/
public static void startServers() {
try {
JCO.addClientPool("POOL", 3, "client", "user" ,"password" , "EN",
"sap_host" ,"system_no");
} catch (RuntimeException e) {
e.printStackTrace();
}
IRepository repository = JCO.createRepository("REP", "H2OPOOL");
for(int i = 0; i < serverConnections.length; i++) {
// Server listens for incoming requests from system 1
// (Change gateway host, service, and program ID according to
// your needs)
serverConnections <i> = new H2ORfcServer
("sap_host", // gateway host, often the same as host
"sapgw00", // gateway service, generally sapgw+<SYSNR>
"PROGRAMID", // corresponds to program ID defined in SM59
repository);
serverConnections <i>.start();
}
}
public static void stopServers() {
for(int i = 0; i < serverConnections.length; i++) {
serverConnections<i>.stop();
}
}
public static void main(String[] args) {
startServers() ;
}
}
I CAN connect three times without a problem to the Server from my R/3 system.
On the fourth call I get on R/3 (yes with those Chinese locking characters):
Call STFC_CONNECTION SY-SUBRC = 1
JCO.Server could not find server function '協䙃彃低久䍔䥏'
dev_rfc.trc logs:
>TS> Wed Apr 30 16:15:04 2008
T:3328 Error in program 'Dummy': <* RfcDispatch [6] : returns 1:RFC_FAILURE
and I get another trace file rfc00704_03328.trc:
**** Trace file opened at , SAP-REL 710,0,0 RFC-VER nU 3 880476 MT-SL
DT ERROR> ab_dtrfcRecvInfo connection id mismatch 6DBD16DDA93DF1498D28001279D0631 <> D0BF16DD11C4F19E8D28001279D0631
After that it sometimes work and sometimes I get this error... Any ideas why??
Update: I added a server State Change Listener and got the following:
Server H2OSERVER changed state from [ STOPPED ] to [ STARTED ]
Server H2OSERVER changed state from [ STOPPED ] to [ STARTED ]
Server H2OSERVER changed state from [ STOPPED ] to [ STARTED ]
Server H2OSERVER changed state from [ STARTED ] to [ STARTED LISTENING ]
Server H2OSERVER changed state from [ STARTED ] to [ STARTED LISTENING ]
Server H2OSERVER changed state from [ STARTED ] to [ STARTED LISTENING ]
Server H2OSERVER changed state from [ STARTED LISTENING ] to [ STARTED LISTENING BUSY ]
handleRequest(STFC_CONNECTION)
request STFC_CONNECTION:
Server H2OSERVER changed state from [ STARTED LISTENING BUSY ] to [ STARTED LISTENING ]
Server H2OSERVER changed state from [ STARTED LISTENING ] to [ STARTED LISTENING BUSY ]
handleRequest(STFC_CONNECTION)
request STFC_CONNECTION:
Server H2OSERVER changed state from [ STARTED LISTENING BUSY ] to [ STARTED LISTENING ]
Server H2OSERVER changed state from [ STARTED LISTENING ] to [ STARTED LISTENING BUSY ]
handleRequest(STFC_CONNECTION)
request STFC_CONNECTION:
Server H2OSERVER changed state from [ STARTED LISTENING BUSY ] to [ STARTED LISTENING ]
Server H2OSERVER changed state from [ STARTED LISTENING ] to [ STARTED LISTENING BUSY ]
Server H2OSERVER changed state from [ STARTED LISTENING BUSY ] to [ STARTED LISTENING ]
Server H2OSERVER changed state from [ STARTED LISTENING ] to [ STARTED ]
Server H2OSERVER changed state from [ STARTED ] to [ STOPPED ]
Server H2OSERVER changed state from [ STOPPED ] to [ STARTED ]
Server H2OSERVER changed state from [ STARTED ] to [ STARTED LISTENING ]
So three times it answers and the it seems to restart on second connection attempt?!
Thanks for help,
Frank
Hi Frank,
Could this be because you create three connections (to your three servers) but never disconnect? Try calling the disconnect first and then connecting again the fourth time. Maybe that would work.
T00th
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
We are gettign a similar error when calling an RFC from SAP-PI. A text fiel is created on desktop with
Trace file opened at , SAP-REL 710,0,0 RFC-VER nU 3 880476 MT-SL
DT ERROR> ab_dtrfcRecvInfo connection id mismatch 4A88BF5F7D8417DFE1000000AC14601 <> 4A6602A51AA617E3E1000000AC14601
Trace file opened at , SAP-REL 710,0,0 RFC-VER nU 3 880476 MT-SL
DT ERROR> ab_dtrfcRecvInfo connection id mismatch 4A88BF5F7D8417DFE1000000AC14601 <> 4A6602A51AA617E3E1000000AC14601
Thanks
Check the UNICODE properties in R/3 and in the JAva code
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.