Hi,
I'm not Java man but I have a working sample that processes OFS message.
Adjust your host/port/JAVA_HOME/OFS.SOURCE/etc settings.
1) java program:
// JCA outbound example (Java)
//
// Author: Alexander Demin
// small changes KZM Friday, 16 May 2014, 13:48:43
// Copyright: Temenos 2009
//
import com.jbase.jremote.DefaultJConnectionFactory;
import com.jbase.jremote.JConnection;
import com.jbase.jremote.JConnectionFactory;
import com.jbase.jremote.JDynArray;
import com.jbase.jremote.JRemoteException;
import com.jbase.jremote.JExecuteResults;
import com.jbase.jremote.JSubroutineParameters;
import java.util.Properties;
import java.io.ByteArrayOutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.io.UnsupportedEncodingException;
public class t24callsub {
private JConnectionFactory factory = null;
public t24callsub(JConnectionFactory f) {
factory = f;
}
public void perform(String subr, String cmd, String host) {
try {
Properties prop = new Properties();
prop.setProperty("allow input", "true");
JConnection c = factory.getConnection(null, null, prop);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
Writer writer = new OutputStreamWriter(bos, "UTF-8");
c.setTerminalOutputWriter(writer);
System.out.println(host + ": CALL " + subr + '(' + cmd + ')');
JSubroutineParameters subroutineParams = new JSubroutineParameters();
subroutineParams.add(new JDynArray(cmd));
subroutineParams = c.call(subr, subroutineParams);
//~ System.out.println(Str.substring(10, 15) );
if (subroutineParams != null) {
String res_all = subroutineParams.toString();
int res_length = res_all.length();
// remove "[<1>"... "]"
System.out.println(res_all.substring(4, res_length-1));
}
c.close();
} catch (UnsupportedEncodingException e) {
System.out.println("Error creating OutputStreamWriter.");
} catch (JRemoteException e) {
//~ System.out.println("Connection or other error.");
System.out.println(e);
//~ e.printStackTrace(); // it goes to stderr
} catch (Exception e) {
System.out.println("Unknown error.");
}
}
public static String strJoin(String[] aArr, String sSep) {
StringBuilder sbStr = new StringBuilder();
for (int i = 3, il = aArr.length; i < il; i++) {
if (i > 3)
sbStr.append(sSep);
sbStr.append(aArr[i]);
}
return sbStr.toString();
}
public static void main(String[] args) {
DefaultJConnectionFactory factory = new
DefaultJConnectionFactory();
// mandatory host
String host = args[0];
factory.setHost(host);
// mandatory port
int port = Integer.valueOf(args[1]);
factory.setPort(port);
// mandatory subroutine name
String subr = args[2];
String extcmd = "";
if (args != null && args.length > 3) {
extcmd = strJoin(args, " ");
t24callsub example = new t24callsub(factory);
example.perform(subr, extcmd, host);
} else {
System.out.println("Wrong number of parameters.");
}
}
}
2) jBC subroutine:
SUBROUTINE kzm_jremofs(param)
$INSERT I_COMMON
$INSERT I_EQUATE
request = param
result = ''
IF PUTENV('OFS_SOURCE=TAABS') THEN NULL
CALL JF.INITIALISE.CONNECTION
CALL OFS.BULK.MANAGER(request, result, '')
CHANGE ',' TO ',':CHAR(10) IN result
param = result
RETURN
END
3) Compile jBC and java. The latter (put commands into cmd file):
@set ROOT=C:\t24
@set JAVA_HOME=%ROOT%\jdk1.6.0_18
@set PATH=%PATH%;%JAVA_HOME%\bin
@set CLASSPATH=%ROOT%\r11\tafc\java\lib\jremote.jar;%CLASSPATH%
javac t24callsub.java
4) Run (another cmd fiile):
@set ROOT=C:\t24
@set JAVA_HOME=%ROOT%\jdk1.6.0_18
@set PATH=%PATH%;%JAVA_HOME%\bin
@set CLASSPATH=%ROOT%\r11\tafc\java\lib\jremote.jar;%CLASSPATH%
@java t24callsub 127.0.0.1 20001 kzm_jremofs
ABBREVIATION,/I/VALIDATE,INPUTT/123456,QWERTY,ORIGINAL.TEXT::=\"123?45\"
Results:
QWERTY//1,
ORIGINAL.TEXT:1:1=123,
45
Cheers
V
On Wednesday, June 18, 2014 6:11:29 PM UTC+5, Vinoth Kumar wrote:
>
>
> Dear All,
>
> How to connect to T24 using java client socket program?
>
> My requirement is from Java program needs to connect T24 jbase_agent port
> once connected, T24 subroutine need to be called.
>
> Is it possible? I’m looking for any sample program for illustration
> purpose.
>
> Thanks and Regards,
>
> Vinoth Kumar TS
>
--
--
IMPORTANT: T24/Globus posts are no longer accepted on this forum.
To post, send email to [email protected]
To unsubscribe, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/jBASE?hl=en
---
You received this message because you are subscribed to the Google Groups
"jBASE" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.