问题
As far as I know, one needs Apache Tomcat or App server like JBoss to deploy and run a web service implemented in java.
My manager asked me, isn't there any alternative to deploy a Web service without configuring or setting up Apache Tomcat/JBoss.
I am basically a QA engineer and have some minimal Java programming experience.
We are trying to develop/implement a Java based Web Service for load generation of SMTP messages which can be invoked by test scripts developed using different technologies (QTP, Perl etc.)
Thanks for your time.
回答1:
Yes, you can run a Webservice simply off the JDK using the @WebService annotation. It even supports SOAP.
Simple example (taken from here, in german):
Service:
@WebService
@SOAPBinding(style=Style.RPC)
public class Calculator {
public long addValues(int val1, int val2) {
return val1 + val2;
}
}
Initialization code:
public class CalculatorServer {
public static void main (String args[]) {
Calculator server = new Calculator();
Endpoint endpoint =
Endpoint.publish("http://localhost:8080/calculator", server);
}
}
回答2:
Web services built in java is basically a Java Application with a different data presentation behavior. you can, just then you have to make them up running when the consumer calls a service. This is how we test them in white box manner.
回答3:
I hope we can, if we use a BINDING protocol as SMTP or CORBA rather than HTTP.
Link : Protocol stack for Web-services.
来源:https://stackoverflow.com/questions/11204688/can-a-java-web-service-hosted-without-deploying-it-on-a-server-like-tomcat-jboss