JAX-WS 服务部署
JAX-WS service deployment
我是 Web 服务编程的新手,正在尝试创建 JAX-WS Web 服务。我在 Eclipse 中创建了以下 JAX-WS web service:
正在创建服务接口:
package test;
@WebService
@SOAPBinding(style = Style.RPC)
public interface AdditionService {
@WebMethod
int add(int a,int b);
}
在那一个实施之后 class:
package test;
@WebService(endpointInterface = "test.AdditionService")
public class AdditionServiceImpl implements AdditionService{
@Override
public int add(int a, int b) {
return a+b;
}
}
最后一步:
通过使用以下代码,我正在发布服务:
package test;
public class AddtionServicePublisher {
public static void main(String[] args) {
Endpoint.publish
("http://localhost:9999/ws/additionService",
new AdditionServiceImpl());
}
}
我可以使用下面的本地 URL 查看 wsdl:
http://localhost:9999/ws/additionService?wsdl
但是因为我没有安装任何服务器。怎么样,要发表了吗?服务器是用eclipse内置的吗?
Oracle Java documentation 声明如下
Creates and publishes an endpoint for the specified implementor object at the given address.
The necessary server infrastructure will be created and configured by the JAX-WS implementation using some default configuration.
由于 JAX-WS 是 Java SE 包的一部分,这意味着底层服务器取决于您 运行 您的程序所在的 JVM 类型。例如。在我的笔记本电脑上,我是 运行 一个 Java 8 OpenJDK,其中创建了一个 "com.sun.net.httpserver.HttpServer" 的实例。
找出在您的环境中启动了哪个服务器的最快方法,只需跳转到 Endoint.java 的(反编译)代码和实现。
如果你想创建一个独立的,self运行 Webservice-jar,你可能有兴趣看看 Spring-WS (with Spring Boot) or Dropwizard。
我是 Web 服务编程的新手,正在尝试创建 JAX-WS Web 服务。我在 Eclipse 中创建了以下 JAX-WS web service:
正在创建服务接口:
package test;
@WebService
@SOAPBinding(style = Style.RPC)
public interface AdditionService {
@WebMethod
int add(int a,int b);
}
在那一个实施之后 class:
package test;
@WebService(endpointInterface = "test.AdditionService")
public class AdditionServiceImpl implements AdditionService{
@Override
public int add(int a, int b) {
return a+b;
}
}
最后一步: 通过使用以下代码,我正在发布服务:
package test;
public class AddtionServicePublisher {
public static void main(String[] args) {
Endpoint.publish
("http://localhost:9999/ws/additionService",
new AdditionServiceImpl());
}
}
我可以使用下面的本地 URL 查看 wsdl:
http://localhost:9999/ws/additionService?wsdl
但是因为我没有安装任何服务器。怎么样,要发表了吗?服务器是用eclipse内置的吗?
Oracle Java documentation 声明如下
Creates and publishes an endpoint for the specified implementor object at the given address. The necessary server infrastructure will be created and configured by the JAX-WS implementation using some default configuration.
由于 JAX-WS 是 Java SE 包的一部分,这意味着底层服务器取决于您 运行 您的程序所在的 JVM 类型。例如。在我的笔记本电脑上,我是 运行 一个 Java 8 OpenJDK,其中创建了一个 "com.sun.net.httpserver.HttpServer" 的实例。
找出在您的环境中启动了哪个服务器的最快方法,只需跳转到 Endoint.java 的(反编译)代码和实现。
如果你想创建一个独立的,self运行 Webservice-jar,你可能有兴趣看看 Spring-WS (with Spring Boot) or Dropwizard。