简体   繁体   English

JAX-WS服务部署

[英]JAX-WS service deployment

I am new to web service programming and trying to create a JAX-WS web-service. 我是Web服务编程和尝试创建JAX-WS Web服务的新手。 I have created the following JAX-WS web service in Eclipse: 我已经在Eclipse中创建了以下JAX-WS Web服务

Creating the service interface: 创建服务接口:

package test;
@WebService
@SOAPBinding(style = Style.RPC)
public interface AdditionService {  
    @WebMethod
    int add(int a,int b); 
}

After that one implementation class: 在那一个实现类之后:

package test;
@WebService(endpointInterface = "test.AdditionService")
public class AdditionServiceImpl implements AdditionService{

    @Override
    public int add(int a, int b) {
        return a+b;     
    }
}

Last step: By using the following code I am publishing the service: 最后一步:通过使用以下代码,我正在发布服务:

package test;
public class AddtionServicePublisher {
    public static void main(String[] args) {
        Endpoint.publish
("http://localhost:9999/ws/additionService", 
new AdditionServiceImpl());

    }
}

I can view the wsdl using the bellow local URL: http://localhost:9999/ws/additionService?wsdl 我可以使用以下本地URL查看wsdl: http://localhost:9999/ws/additionService?wsdl

But as I don't have any server installed. 但由于我没有安装任何服务器。 How, it is getting published? 如何发布? Is server is inbuilt with eclipse? 服务器内置eclipse吗?

The Oracle Java documentation states the following Oracle Java 文档指出以下内容

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实现将使用某些默认配置来创建和配置必要的服务器基础结构。

As JAX-WS is part of the Java SE package, this means the underlying server is depending on what kind of JVM you are running your program at. 由于JAX-WS是Java SE软件包的一部分,因此这意味着底层服务器取决于您在其上运行程序的JVM的类型。 Eg on my laptop I am running a Java 8 OpenJDK, in which an instance of "com.sun.net.httpserver.HttpServer" is created. 例如,在我的笔记本电脑上,我正在运行Java 8 OpenJDK,在其中创建了“ com.sun.net.httpserver.HttpServer”的实例。

The fastest way to find out what server ist started in your environment, just jump into the (decompiled) code of the Endoint.java and the implementation(s). 找出您的环境中启动了哪些服务器的最快方法,只需跳入Endoint.java和实现的(反编译)代码即可。

If you want to create a standalone, selfrunning Webservice-jar you might be interested to take a look at Spring-WS (with Spring Boot) or Dropwizard . 如果您想创建一个独立的,自运行的Webservice-jar,您可能有兴趣看看Spring-WS (带有Spring Boot)或Dropwizard

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM