Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在开发JAX-WS Web服务时删除注释并添加xml_Java_Web Services_Jax Ws - Fatal编程技术网

Java 在开发JAX-WS Web服务时删除注释并添加xml

Java 在开发JAX-WS Web服务时删除注释并添加xml,java,web-services,jax-ws,Java,Web Services,Jax Ws,我是web服务世界的新bie,我在开发JAX-WS时有一个问题,下面的web服务包括生产者和客户端,但我使用的是注释。您能告诉我如何在不使用使用XML注释的情况下开发相同的程序吗..本身 创建Web服务端点接口 import javax.jws.WebMethod; import javax.jws.WebService; import javax.jws.soap.SOAPBinding; import javax.jws.soap.SOAPBinding.Style; //Service

我是web服务世界的新bie,我在开发JAX-WS时有一个问题,下面的web服务包括生产者和客户端,但我使用的是注释。您能告诉我如何在不使用使用XML注释的情况下开发相同的程序吗..本身

创建Web服务端点接口

import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;

//Service Endpoint Interface
@WebService
@SOAPBinding(style = Style.RPC)
public interface HelloWorld{

    @WebMethod String getHelloWorldAsString(String name);

}
创建Web服务端点实现

import javax.jws.WebService;

//Service Implementation
@WebService(endpointInterface = "com.mkyong.ws.HelloWorld")
public class HelloWorldImpl implements HelloWorld{

    @Override
    public String getHelloWorldAsString(String name) {
        return "Hello World JAX-WS " + name;
    }

}
创建端点发布服务器

import javax.xml.ws.Endpoint;
import com.mkyong.ws.HelloWorldImpl;

//Endpoint publisher
public class HelloWorldPublisher{

    public static void main(String[] args) {
       Endpoint.publish("http://localhost:9999/ws/hello", new HelloWorldImpl());
    }

}
通过Wsimport工具的Java Web服务客户端

wsimport -keep http://localhost:9999/ws/hello?wsdl
它将生成必要的客户机文件,这取决于提供的wsdl文件。在这种情况下,它将生成一个接口和一个服务实现文件

最后,使用生成的存根类创建主类

package com.mkyong.client;

import com.mkyong.ws.HelloWorld;
import com.mkyong.ws.HelloWorldImplService;

public class HelloWorldClient{

    public static void main(String[] args) {

        HelloWorldImplService helloService = new HelloWorldImplService();
        HelloWorld hello = helloService.getHelloWorldImplPort();

        System.out.println(hello.getHelloWorldAsString("mkyong"));

    }

}

我遇到这个问题时也遇到了同样的问题

终于在这里找到了所需的解释:

查找:覆盖注释

这里有一个很好的方法让您开始使用jaxws(jdk中默认的jaxws实现基于metro)。