Samedi 14 octobre 2006
6
14
/10
/Oct
/2006
19:36
Purpose
Here is a Java bean that allows to transform a Forms module into a socket server.
This way, it can receive messages from the outside.
- In this example, the messages are sent through a telnet session.

In this sample dialog, I have opened a telnet session:
open localhost 4450
Then I can send messages to the Forms application.
- In another way, messages can also be sent by the database:
DECLARE
c utl_tcp.connection; -- TCP/IP connection to the Socket server
ret_val PLS_INTEGER;
BEGIN
c := utl_tcp.open_connection(remote_host => '10.40.40.40',
remote_port => 4450); -- open connection
ret_val := utl_tcp.write_line(c, 'Incoming Message Send by my Oracle DB');
utl_tcp.close_connection(c);
END;
The Java code
SocketServer.java Server.java
The implementation class of the Bean Item
oracle.forms.fd.SocketServer
The methods you can call
Init the socket server
Set_Custom_Property('BLOCK.ITEM', 1, 'INIT_SERVER', 'port_number');
e.g. :
Set_Custom_Property( 'BL.BEAN', 1, 'INIT_SERVER', '4450' ) ;
The event received from the Bean
SENDMSG
this event tells Forms that a message is sent by the Java Bean.
You can get it in a WHEN-CUSTOM-ITEM-EVENT event:
DECLARE
eventName varchar2(30) := :system.custom_item_event;
eventValues ParamList;
eventValueType number;
LC$Msg varchar2(512);
LC$Value varchar2(256);
BEGIN
IF (eventName='SENDMSG') THEN
eventValues := get_parameter_list(:system.custom_item_event_parameters);
get_parameter_attr(eventValues,'MESSAGEVALUE',eventValueType, LC$Msg);
-- Display the message --
:BL.MSGS := :BL.MSGS || LC$Msg || Chr(10) ;
Synchronize ;
END IF;
END;
The sample dialog
. Download the socketserver.zip file
. Unzip the file
. copy the socketserver.jar file in the <ORACLE_HOME>/forms/java directory
. Edit your /forms/server/formsweb.cfg file
. Open the SOCKETSERVER.fmb module (Oracle Forms 9.0.2)
. Compile all and run the module
the jar file must be signed.
the jar file provided in this article is already signed.
Par Oracle Forms community
-
Publié dans : Bean - general
6
Dear Sirs
I tried the
Send message to Forms from the outside ? yes you can !
I am using Forms Builder 10g version 10.1.2.0.2
Compiling the Form is no problem, but running it i recieve the following error
java.lang.UnsupportedClassVersionError: oracle/forms/fd/SocketServer (Unsupported major.minor version 49.0)
searching internet i found a couple of entries related to the version of JDK being 1.4 instead of 1.5.
Can you share some light on this issue?
Best Regards
Torben
If you use JInitiator, the .jar file have to be recompiled with the 1.3 JRE target JDdeveloper settting.
I will generate this particular .jar file and put it in the zip file. ;o)
Francois
Hi Francois
Thanks for your quick response.
I also figured this out reading your comments elsewhere recommending the general use of the SUN Java plug-in instead of the JInitiator.
Also thanks for providing the JInitiator JAR file
Best Regards
Torben
Hello Francois
Thanks a lot for the Jinitiator update, it works with the Jinitiator update.
Having to deliver Proof of Concept regarding Forms being able to recieve the Response from an Oracle Database Advanced queue,
and having read the Oracle White paper
Building Internet Applications with Oracle Forms 6i and Oracle8i
An Oracle Technical White Paper
March 2000
on Which i have seen your recommandation on Technet.
This solution seems rather complicated though and is for Forms 6i and the 8i DB,
as i stated we will be using Forms 10g 10.1.2.0.2 and a 10g DB
and my immediate idea was to maybe shortcut this using the SocketServer variant and
just to have a DB Stored procedure call the Socket Server without involving the AQ in first place.
My deduction is that if the stored procedure can call the Socket Server then in a second step i can combine this with the AQs later on.
In the First place i could make a stored procedure that via Java Stored procedure calls telnet on the OS and sends a Message to the Forms socketServer,
The forms could then react to this message, so having provided a first Proof of Concept as to Forms being able to react to a generel DB event.
I know its to much to hope for an comment on a Solution path for the proof of concept,
but i thought id give a shoot anyway.
Best regards
Torben
Hi Francois
The solution to this is so simple that i should be ashamed to have asked you the question ;-)
DECLARE
c utl_tcp.connection; -- TCP/IP connection to the Socket server
ret_val pls_integer;
BEGIN
c := utl_tcp.open_connection(remote_host => 'localhost',
remote_port => 4450); -- open connection
ret_val := utl_tcp.write_line(c, 'Incoming Message Send by my Oracle DB');
utl_tcp.close_connection(c);
END;
/
Thanks again and best regards
Torben
Why do we have to have a static thread object in the SocketServer and why do we have this condition in its run method:
Thread theThread = Thread.currentThread();
while (runner == theThread)
{
?
Thanks
I tried to use your bean in my main screen. I have some links in main screen, which opens other forms. Our goal was when we recieve a message in port, we wanted to show a form on top of other existing forms. It does the job, if there is only main screen. But, when we open a new form [using call_form or open_form] whenever a message is recieved an error message is shown 'cannot navigate to main_screen'. Then we tried to close the socket before opening other forms. And, opening the socket from the new form. But, this was not successful either. Because, we were unable to stop the socket server from listening. Only way, we could do this by showing two consecutive messages. And, only after that, the socket stops listening! Any idea how to resolve the issue? My question is why the socket server is not stopping as soon as we call set_custom_property passing 'STOP_SERVER' ?
Thanks in advance.