Hi Friends
I had a requirement to make call to Forte 4GL from Java. So we opted Web Services as solution.
And while doing the “Hello World” kind of application, I found some things and I would share with you all.
In this scenario I had by Forte 4GL as Web Service provider and Java as Web Service Requester.
Step 1 Forte 4GL Code
a. Create a plan – HelloWorldServer
b. Create a non window class called – HelloWorldMgr
c. Create attribute name of type TextData
d. Create a method printHelloWorld() return type of TextData.
Inside the method write the following lines of code.
task.lgr.putline('Hello World called -- Forte Output');
name = 'Srikanth';
return name;
e. Select the class and go to component and select Extended properties and create a new name called “XMLStruct”. All the classes to be exposed as Web Service should have extended property of type “XMLStruct”.
f. Create a Service Object – soHelloWorld, give the class of previously created Class name (HelloWroldServer).
Step 2 (Forte Partition Workshop). Deploy this project as server
a. Partition as Server.
b. Select the Service object, which has to be exposed as Web Service and give the host name port number, where this will be installed, so that later Java Client application can call though this Host and port.
Double click service object in partition workshop and select the Export tab and click on more export options and give the hostname and port.
c. And do make distribution from Partition Workshop.
d. You can do Local and do Full Make.
e. After this step forte will create Java Classes for the Forte Server in your local appdist directory (D:\forte\appdist). Since we said local before.
f. You will see java classes in example:- D:\forte\appdist\5052env1\hellowor\cl0\generic\hellow1\java\com\forte\xmlsvr\helloworldserver
g. Open the Environment Console, Load the new application and Install the new application.
h. Forte Server side is done.
3. Java Client application to call the Forte Web Services.
Call the proxy generated from Forte.
Sample
package com.xxx.yyy;
import com.forte.xmlsvr.helloworldserver.HelloWorldSOProxy;
import com.forte.xmlsvr.providerbo.Provider;
public class HelloWorldMain {
/**
* @param args
*/
public static void main(String[] args) {
HelloWorldSOProxy helloWorldSOProxy = new HelloWorldSOProxy();
try {
String name = helloWorldSOProxy.printHelloWorld();
System.out.println("Java code, return from forte server " + name);
} catch (Exception e) {
e.printStackTrace();
}
}
}
More detail information about this is given in book Integrating with External Systems iPlanet™ Unified Development Server Version 5.0 pages 127 – 156.
Using this as my basis I have build a complete application. This example really help me.
If you have any question on this, Please let me know.