views:

78

answers:

3

We have a large system of physical devices which all run a web service for control and a central control system for controlling these devices. I need to make a substitute for such a physical device in order to test the controlling unit. How will I go about running more than one instance of a test device on a single computer. The protocol used in SOAP with a wsdl written in stone. In addition to the webservice each test device needs a webserver to monitor state and generating events.

My first approach is to embed jetty and use axis2 for webservices, but I am having some trouble making that fly. I managed to get the axis2 SimpleHttpServer working with a webservice, but as far as I can tell SimpleHttpServer will not let me run Servlets or let alone wars. Is there a better approach I am missing?

I considered making a proxy server listening on any number of ports and forwarding the request to a webservice to a central webservice with an additional paramater saying which port the request originated from, but since the wsdl is writting in stone I can not pass this paramater along.

EDIT: I am using Netbeans to generate a webservice for me. Works as a charm but not enough for my project. For some reason wsimport chokes on the wsdl. I don't understand how Netbeans can deploy to the bundled Glassfish server, but if I drop the generated dist/my-project.war into tomcat the webservice doesn't work. Much less show up in web.xml. What am I missing?

A: 

Axis2 is not meant to be used as a servlet container, so using SimpleHttpServer doesn't help you there.

But Jetty is a full featured Servlet container. If you want to make it work, you have to run your Wars with Jetty. (Or any other servlet container, but Jetty is perfectly fine)

I'm not Jetty expert, but this should work:

Server server = new Server(8080);
Context root = new Context(server, "/", Context.SESSIONS);
root.addServlet(new ServletHolder( yourServletInstance ), "/*");
server.start();

(Taken from Jetty Wiki)

DR
So what are the steps required to run webservices in jetty
Esben Skov Pedersen
Updated my answer.
DR
Where is yourServletInstance coming from and what tools should i use to make it?
Esben Skov Pedersen
It's an instance of the servlets you mentioned in your question. Normally they can just be instantiated like any POJO, `new MyWebServiceServlet()`, unless you designed your servlet to be instantiated in any other way. (Factory or something)
DR
Yes, that will run servlets, but not webservices
Esben Skov Pedersen
I thought that was at least one of the problems you have...?
DR
Well I can run servlets and I can run webservices, but not on the same server which is my main problem.
Esben Skov Pedersen
OK, sorry, I obviously misunderstood your question.
DR
Perhaps you can split your original question into different specialized questions and ask them separately. That might get you more answers.
DR
ok, I might consider that. I am reading up on the different implementations of webservices. I am coming from a .NET background and am wondering why everything has to be so complicated in java. To be fair I don't know how to do it in .NET but I probably won't have to choose between so many different frameworks and implementations of the same interface
Esben Skov Pedersen
A: 

Be aware that if you route your network requests through a SOCKS proxy, you can essentially redirect even hardcoded names and ports in the SOCKS proxy to whatever you need.

Thorbjørn Ravn Andersen
The control system does not support SOCKS and it is made by a different vendor so that's a NO GO.
Esben Skov Pedersen
Schade. Then consider putting a Transparent Proxy in front of the control system which allows you to proxy any traffic. http://www.faqs.org/docs/Linux-mini/TransparentProxy.html#s2
Thorbjørn Ravn Andersen
Thorbjørn, I've implemented a proxy server in Jetty. Then I realized it won't solve my problem since I don't know how to run multiple instances of the same webservice on the same machine.
Esben Skov Pedersen
A: 

Ok I've figured out a solution. I can use Glassfish. Then I deploy the same webapp multiple times under different names. Then I have a small proxy made in glassfish which listens on a number of ports and then translates the request to one of the instances running i glassfish.

Esben Skov Pedersen