Implement a Websocket server using COBOL and Java in Visual Eclipse

Hi

I'm porting a large desktop MicroFocus  application that is currently compiled to gnts  onto the Web. I'm using Eclipse 2.2.2 on Windows 10. The app will deployed on a Windows Server 2010 or later.

The old architecture uses a sockets C program, compiled to a dll that was itself called by a compile Cobol gnt.

Here's an extract from the COBOL program that called the sockets.dll

01 W00SOC-REC PIC X(6144).
01 ws-msg PIC X(6145).

string w00soc-rec x"00" delimited by size into ws-msg
call dynamicNTStdCall "sockets" using ws-msg

 The other side of the socket connection is a Java program that paints a Gui screen using the passed information at run time.

Gnts needing to  use the sockets Cobol program pass W00SOS-REC in linkage.

As far as I can tell there is no native support for sockets on the Web, apparently for security reasons. However there is socket like protocol "Websockets" that is widely supported.

I can install and use Tomcat to deploy a Websockets service on the server side. That part seems fairy straightforward. If anyone is interested please see this link which has very good instructions:

https://examples.javacodegeeks.com/enterprise-java/tomcat/apache-tomcat-websocket-tutorial/

The Java Websockets code  reproduced below.

My question is how to create a new JVM Cobol program that can call the Java program and be callable from my native gnts.

I'm assuming it need to be compiled as managed code so that it can call the Java program. The only data mapping that is required is the COBOL string

01 W00SOC-REC PIC X(6144).

I would really appreciate it if anyone could steer me in the right direction or provide help with:

1) links or instructions to setup the Eclipse project for the managed code

2) an example program that passes and receives strings to and from Java

Please let me know if the whole concept is flawed and not possible :)

Thanks in advance

Elliot

 

 

 

Websockets Java code:

package server.ws;

import javax.websocket.OnClose;
import javax.websocket.OnError;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
import javax.websocket.server.ServerEndpoint;

@ServerEndpoint("/websocketendpoint")
public class WsServer {

@OnOpen
public void onOpen(){
System.out.println("Open Connection ...");
}

@OnClose
  public void onClose(){
  System.out.println("Close Connection ...");
}

@OnMessage
public String onMessage(String message){
  System.out.println("Message from the client: " message);
  String echoMsg = "Echo from the server : " message;
  return echoMsg;
}

@OnError
  public void onError(Throwable e){
  e.printStackTrace();
}

}

Parents
  • Hi Michael
    The current architecture is synchronous on the client side since the socket server waits for a message from the server. I understand that "polling" is a work around to overcome the asynchronous nature of HTTP.

    So I googled "synchronous http call in angularJS" and found the following thread.

    stackoverflow.com/.../synchronous-http-call-in-angularjs

    In summary it says to "Take a look at promises to overcome such issues, because they are used all over the place, in angular world"

    Are you at all familiar with this and if so what do you think in the context or our discussion?

    Thanks
Reply
  • Hi Michael
    The current architecture is synchronous on the client side since the socket server waits for a message from the server. I understand that "polling" is a work around to overcome the asynchronous nature of HTTP.

    So I googled "synchronous http call in angularJS" and found the following thread.

    stackoverflow.com/.../synchronous-http-call-in-angularjs

    In summary it says to "Take a look at promises to overcome such issues, because they are used all over the place, in angular world"

    Are you at all familiar with this and if so what do you think in the context or our discussion?

    Thanks
Children
No Data