Thursday, January 31, 2008

Status Report for 12/26/2007 -- 01/09/2008

Progress

1. Design for server side (Embedded Jetty)

In this design, we embedded Jetty into our Java applications and used it as the core HttpServer, an HTTP server with the ability to serve static content and servlets.

The basic idea is to implement a handler in the servlet and start a jetty server with it. Once the jetty server gets a request from the jetty port, the handler will get the parameters and start SimpleAxisServer(SAS) to call a CIMA web service and then get the data at a listener of SAS.

2. Implementation

(1) Create an instance of the Jetty server (org.mortbay.jetty.Server) listening at some port, but does not start the server.

Server server = new Server();

Connector connector=new SelectChannelConnector();

connector.setPort(some port);

server.setConnectors(new connector[]{connector});

(2) Add resource handlers which will get the parameters from the client’s request and start the web service.

Handler param = new ParamHandler();
Handler rqst = new RqstHandler();
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[]{rqst, param});

server.setHandler(handlers);

(3) Start the Jetty server.

server.start();

server.join();

(4) Set up the embedded axis server with deployment descriptor generated by WSDL2Java

SimpleAxisServer server = new SimpleAxisServer();

ServerSocket WSserverSocket = new ServerSocket(someport);

WSserverSocketPort = WSserverSocket.getLocalPort();

server.setServerSocket(WSserverSocket);

server.setMyConfig(wsdddoc.getDeployment());

server.start();

set up the call to the CIMA service


String endpointURL = new String(some IP address);
Call call = new Call(endpointURL);
call.setTargetEndpointAddress( new java.net.URL(endpointURL) );
call.setOperationName(somename);
call.addParameter(……);

call.invokeOneWay(……);

Discussion

On the client side, Ajax is being used for this web application. In a standard way, making a request to a servlet/JSP page on the server in Tomcat would be much easier and convenient. So instead of using embedded Jetty, we can just use servlet/JSP page to get the parameter and call a web service and send the response to client. In that case, everything on the server is running in the Tomcat, and just one port is necessary.

No comments: