× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Dean,

I have created a "common" procedure that I use when working with Java
strings.

When invoking a Java method I use something like the below. This sample is
calling the "setter" of an instance variable in my Java class. It requires
a "String" to be passed into the method, so I use my procedure newString()
to set the variable up correctly.
setIpAddress(pCsv: newString(pIpAddress));


In your example, it would be something like the below. Set up the class
name in the D-specs to make things easier when referring to the class. I
am guessing a bit based on what I read in your post, so you may need to
experiment a bit.
D className c '
cincom.eloquence.exits.gsm.token.UniversalToken'

To invoke the method, use your procedure that you have now prototyped
using WDSC.
getUniversalToken(className, newString(Mykey), newString(expireMinutes))





The prototype for my function looks like this:

D jStrConst c 'java.lang.String'

D newString pr O class(*java: jStrConst)
D pString 32767a const


And my module looks like this. Change the error handling routine to match
your own requirements.

/**
* newString()
*
* @descr Create Java string object.
* @usage newString("Text");
* @param pString Text string to initialise the String object.
* @return Java string object.
*/
P newString b export
D newString pi o class(*java: jStrConst)
D pString 32767a const

D string s o class(*java: jStrConst)

D error ds likeds(Error_Info) inz

// Local prototype to build a java "String" object (using
java.lang.String)
D newJavaString pr o extproc(*java: jStrConst:
D *constructor)
D class(*java: jStrConst)
D parm 32767a const

// Local prototype to java "trim" method (using java.lang.String.trim)
D trimString pr o extproc(*java: jStrConst: 'trim')
D class(*java: jStrConst)
/free

monitor;
string = newJavaString(%Trim(pString));
return trimString(string);
on-error *All;
error = Error_catch();
Error_throw(
'XCOMMON_001'
: 100
: 'newString'
: error.code + ': ' + error.text);
endmon;

/end-free
P newString e


Regards






From:
Dean Eshleman <Dean.Eshleman@xxxxxxxxxxxx>
To:
"rpg400-l@xxxxxxxxxxxx" <rpg400-l@xxxxxxxxxxxx>
Date:
20/09/2012 06:47 AM
Subject:
Calling Java from RPG take 2
Sent by:
rpg400-l-bounces@xxxxxxxxxxxx



In order to interface with some third party software, I need to call some
Java code that they provided to generate a token. My experience with Java
is mainly what I have read in articles. The statement they gave me was

String tokenValue = cincom.eloquence.exits.gsm.token. UniversalToken.
getUniversalToken(Mykey, expireMinutes)

Mykey is a java string and the expireMinutes is an integer. Thanks to the
previous thread about calling Java, I used the wizard in WDSC to create
the prototypes for calling the Java method. Thanks Joe! What I am
struggling with is how do I move data between a Java string variable and
an RPG character variable? I am guessing I need to create a new instance
of the Mykey field and somehow assign a value to it. I need to do this
with the Mykey field and the tokenValue field.

Dean Eshleman
Software Development Architect

Everence Financial
1110 North Main Street
PO Box 483
Goshen, IN 46527
Phone: (574) 533-9515 x3528
www.everence.com<http://www.everence.com>



________________________________________
Confidentiality Notice: This information is intended only for the
individual or entity named. If you are not the intended recipient, do not
use or disclose this information. If you received this e-mail in error,
please delete or otherwise destroy it and contact us at (800) 348-7468 so
we can take steps to avoid such transmission errors in the future. Thank
you.
_______________


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.