My goal is to invoke a Java web service initiated with an RPG function. (I know its a long way, but that is what we need)
I created the /JavaLib folder on the AS400 and copied all the external Jars we need.
Create a Java class with the static method WebServiceCaller.Call() to call the web service. When I run my RPG program, everything is fine when the RPG calls this method.
I get a Java exception:
Message. ,,: Java exception received when calling the Java method (CGD F).
Reason. ,,: RPG procedure WEBSERCALR in program WAL60326 / WEBSERCALR received Java exception "java.lang.NoClassDefFoundError:
javax.xml.rpc.ServiceException "when calling the Call method with the signature" (LwebService.Input;) LwebService.Output; "in the class
"WebService.WebServiceCaller".
CLASSPATH variable:
/ JavaLib: / Home / WAL60326 / WebServiceCaller
So, I believe that my RPG and Java class are fine, and I believe that I have correctly set my CLASSPATH variable. Not sure what else to check.
Update
So I need a jar file jaxrpc.jar ; it exists in my /JavaLib . Could check my version of Java on AS400 java version "1.5.0" . And follow these instructions to verify that my OS is V6R1.
Maybe my version of Java is deprecated since this Jar file is loading / working? Is this even an opportunity?
Edit
Here is my source code:
Java: WebServiceCaller.Java
package webService; import java.rmi.RemoteException; import stocklistGetBids.GetBidsProxy; public class WebServiceCaller { public static Output Call(Input in) {
Note that the GetBidsProxy class is created in Eclipse. And the Java side works well on my Windows machine. Just not on an AS400.
RPG: WEBSERCALR.RPGLE
H DFTACTGRP(*NO) H thread(*serialize) D WebsercalInput DS D ReturnCode 7A D LogKey 20A D ID 20A D jString SO CLASS(*JAVA:'java.lang.String') D jLogKey SO CLASS(*JAVA:'java.lang.String') D jID SO CLASS(*JAVA:'java.lang.String') D Input SO CLASS(*JAVA:'webService.Input') D Output SO CLASS(*JAVA:'webService.Output') D new_Input PR O EXTPROC(*JAVA: D 'webService.Input': D *CONSTRUCTOR) D LogKey like(jString) D ID like(jString) D new_String PR O EXTPROC(*JAVA: D 'java.lang.String': D *CONSTRUCTOR) D bytes 30A CONST VARYING D Call PR like(Output) D EXTPROC(*JAVA: D 'webService.WebServiceCaller': D 'Call') D STATIC D in like(Input) D getReturnStat PR O EXTPROC(*JAVA: D 'webService.Output': D 'getReturnedStatus') D CLASS(*JAVA:'java.lang.String') D getBytes PR 65535A VARYING D EXTPROC(*JAVA: D 'java.lang.String': D 'getBytes') C *ENTRY PLIST C PARM WebsercalInput /free jLogKey = new_String(LogKey); jID = new_String(ID); Input = new_Input(jLogKey:jID); Output = Call(Input); jString = getReturnStat(Output); ReturnCode = getBytes(jString); return; /End-Free