Can a Java Web Service hosted without deploying it on a server like Tomcat/JBoss?

社会主义新天地 提交于 2020-01-13 11:26:48

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!