|
Chad, Here is an example program. I stripped out a lot of RPG code and am showing the java related RPG. Kristen > -----Original Message----- > From: java400-l-bounces@xxxxxxxxxxxx > [mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of cornelius, chad > Sent: Wednesday, September 14, 2005 11:29 AM > To: 'Java Programming on and around the iSeries / AS400' > Subject: Another RPG calling Java issue > > > I am still having trouble calling a simple java program from > RPG. Below is what my java class looks like: > > > > public class PostOutBoundXml { > > > > public void postXml(String arg) { > > try { > > String endpoint = > "http://localhost/axis/services/SancaXmlService"; > > Service service = new Service(); > > Call call = (Call) > service.createCall(); > > > call.setTargetEndpointAddress(new URL(endpoint)); > > call.setOperationName("postXml"); > > call.invoke(new Object[] {arg}); > > } catch (Exception e) { > > e.printStackTrace(); > > } > > } > > } > > > > Here is my prototype: > > D postXml PR EXTPROC(*JAVA: > > > D > 'us.co.state.judicial.sanca.+ > > D client.iseries.+ > > > D > PostOutBoundXml':'postXml') > > D* strObj O > Class(*JAVA:'java.lang.String') > > > ********************************************************************* > > * newString constructor that accepts a byte array > > > * (an alphnumeric variable in RPG speak). It > > > * returns a string object. > > > > ********************************************************************* > > D newString PR O ExtProc(*JAVA: > > > D > 'java.lang.String': > > D *CONSTRUCTOR) > > > D > Class(*JAVA:'java.lang.String') > > D charParm 100A > > > > > I have commented out the input String parameter for prototype > postXml because the RPG program will not compile: The error > is "The call passed fewer parameters than the prototype > indicates are required." However, if I comment out the input > param, everything compiles fine but I get an exception > "java.lang.NoSuchMethodError: postXml" when calling method > "postXml" with signature "()V" in class. Below is the RPG: > > > > H DftActGrp(*NO) ActGrp(*CALLER) > > > > /Copy *LibL/QRpgLeSrc,XmlOutPR > > > > D strObj S O CLASS(*JAVA:'java.lang.String') > > D string S 100A > > > > C/FREE > > string = '<TEST>'; > > strObj = newString(string); > > postXml(strObj); > > > > Eval *inLR = *on; > > /END-FREE > > > > Any help would be greatly appreciated. I am about to pull my > hair out with > this stuff. > > > > Thanks, > > Chad Cornelius, IIS > > (720) 921-7835 > > > > -- > This is the Java Programming on and around the iSeries / > AS400 (JAVA400-L) mailing list To post a message email: > JAVA400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change > list options, > visit: http://lists.midrange.com/mailman/listinfo/java400-l > or email: JAVA400-L-request@xxxxxxxxxxxx > Before posting, please take a moment to review the archives > at http://archive.midrange.com/java400-l. > > >
H/TITLE INPUT SPECS F**************************************************************** F* F* DESCR: Credit card settlement for one order or all F* qualified orders. F* PGM NAME: WBCCSTL F* DATE: Sept 10, 2005 F* AUTHOR: HENRYK F* NOTE: To compile this program it must be compiled using: F* CRTRPGMOD MODULE(WSCTSTOBJ/WBCCSTL) SRCFILE(WSCTSTOBJ/QRPGLESRC) F* (with the appropriate library and library list) F**************************************************************** .... .... *----------------------------------------------------------------- * Define Java Gift Card Java program *----------------------------------------------------------------- D j_Gc S O Class(*Java : D 'com.samsonite.+ D GiftCard') *----------------------------------------------------------------- * Define Java Class Constructor *----------------------------------------------------------------- D j_GcConst PR O EXTPROC(*Java : D 'com.samsonite.+ D GiftCard': D *CONSTRUCTOR) *----------------------------------------------------------------- * Define Java Methods *----------------------------------------------------------------- D j_rqsSettle PR EXTPROC(*JAVA: D 'com.samsonite.giftcard.+ D GiftCard' : D 'requestSettleDeposit') D gcTrxId O Class(*JAVA : 'java.lang.String') D gcAmount O Class(*JAVA : 'java.lang.String') * D j_getTotAmt PR O EXTPROC(*JAVA: D 'com.samsonite.giftcard.+ D GiftCard' : D 'getOutTotalAmount') D Class(*JAVA : 'java.lang.String') *----------------------------------------------------------------- * Field declarations *----------------------------------------------------------------- D j_gcTrxId S O Class(*JAVA : 'java.lang.String') D j_gcAmount S O Class(*JAVA : 'java.lang.String') D j_result S O Class(*JAVA : 'java.lang.String') * D result_s S 8A D result S 8P 2 D len S 5I 0 D tmp S 8A *----------------------------------------------------------------- * Procedure: newString * Purpose: Create a Java String Object from a character field *----------------------------------------------------------------- D newString PR O EXTPROC(*Java: D 'java.lang.String': D *CONSTRUCTOR) D bytes 50A Const Varying *----------------------------------------------------------------- * Procedure: getBytes * Purpose: Get bytes from java string to place in char field *----------------------------------------------------------------- D getBytes PR 7A EXTPROC(*JAVA: D 'java.lang.String': D 'getBytes') Varying C**************************************************************** .... .... C/TITLE ***************************************************************** * MAINLINE ***************************************************************** * ...... ...... ********************************************************************* * Subroutine: Settle Gift Card ********************************************************************* C gcSettle Begsr * C Eval SomeGCMrkd = 'Y' * * Set the values of Transaction Id and Amount C Eval j_gcTrxId = newString(OhGcTx) C Eval len = %len(%Char(OhGcAm*100)) C Evalr tmp = %subst(%Char(OhGcAm*100): C 1 : (len-3)) C Eval j_gcAmount=newString(tmp) C Eval result = 0 C Eval result_s = '0' * C Monitor * * If the GiftCard java program is not instantiated, do it C If j_Gc = *null C Eval j_Gc = j_GcConst C Endif * C Callp j_rqsSettle(j_Gc : j_gcTrxId : j_gcAmount) * * Get the total amount settled on the card C Eval j_result = j_getTotAmt(j_Gc) * C If j_result <> *null C Evalr result_s = getBytes(j_result) C Else C Evalr result_s = '0' C Endif * C On-Error *ALL * C Endmon * C Move result_s result C ENDSR *===================================================
As an Amazon Associate we earn from qualifying purchases.
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.