java - 在哪里使用wsgen?

标签 java jax-ws wsgen

似乎不知道在哪里(什么目录 - 源或类)针对我的 WebService 类正确使用 wsgen...

创建一个基于 WebService 的示例文档文字:

package hello;

import javax.jws.WebService;

@WebService
public class HelloWorld {

public void sayHello() {
        System.out.println("Welcome to JAX-WS 2!");
    }
}

像这样创建发布者:

package hello;

import javax.xml.ws.Endpoint;

public class Publisher {
    public static void main(String[] args) {
        Endpoint.publish("http://localhost:8080/jaxws/hello", new HelloWorld());
    }
}

使用 Eclipse Helios,我自动将这两个文件构建为相应类目录下的 *.classes。

所以,从文件系统来看,我的项目是这样的:

/code/jws_sample
          |
          src
             |
              hello
                  |
                  HelloWorld.java
                  Publisher.java
          |
           classes
                    |
                    HelloWorld.class
                    Publisher.class

我将在哪个目录中运行 wsgen?

当我在里面尝试时:

/code/jaxws_sample/src/wsgen -cp 。你好.HelloWorld

收到:

  Class not found: "hello.HelloWorld"

  Usage: WSGEN [options] <SEI>

  where [options] include:

  -classpath <path>          specify where to find input class files

  -cp <path>                 same as -classpath &lt;path&gt;

  -d <directory>             specify where to place generated output files

  -extension                       
                             allow vendor extensions - functionality not specified
                             by the specification.  Use of extensions may
                             result in applications that are not portable or
                             may not interoperate with other implementations
   -help                     display help

   -keep                     keep generated files

   -r <directory>            resource destination directory, specify where to
                             place resouce files such as WSDLs

   -s <directory>            specify where to place generated source files

   -verbose                  output messages about what the compiler is doing

   -version                  print version information

   -wsdl[:protocol]          generate a WSDL file. The protocol is optional.
                             Valid protocols are [soap1.1, Xsoap1.2],
                             the default is soap1.1.
                             The non stanadard protocols [Xsoap1.2]
                             can only be used in conjunction with the
                             -extension option.

   -servicename <name>       specify the Service name to use in the generated WSDL
                             Used in conjunction with the -wsdl option.

   -portname <name>          specify the Port name to use in the generated WSDL
                             Used in conjunction with the -wsdl option.

   Examples:

   wsgen -cp . example.Stock
   wsgen -cp . example.Stock -wsdl -servicename {http://mynamespace}MyService

它实际上确实在浏览器中向我展示了 WSDL,而且当我尝试从 $MyProject/classes 发出 wsgen 命令时,它实际上确实创建了一个包含 SayHelloResponse.class 文件而不是 SayHelloResponse.java 文件的 jaxws 文件夹?

感谢您花时间阅读本文。

最佳答案

看起来你必须先将文件编译成类文件,然后将它们提供给 wsgen。

classpath <path>          specify where to find input **class files**

我可能是错的,但我相信我过去也必须这样做。

谢谢,

杰弗里·凯文·普赖

关于java - 在哪里使用wsgen?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6460258/

相关文章:

java - Spring Security - 使用主体登录 OAuth/Google 后如何检索数据(如电子邮件、姓名、图片等)?

java - 如何向 JAX-WS Web 服务处理程序提供参数?

java - 如何通过 ssl 从 wsdl 生成 jax ws 工件

web-services - maven jax-ws 插件不会从 wsdl 生成客户端类

java - jax-ws: "keep"工具中的 "wsgen"标志究竟有什么作用?

java - 在 Maven 中生成的 Web 服务不支持 Major.Minor 版本 51.0

java - 需要帮助使用 SingleFrameApplication 来保存 session

java - java不适合被多次调用的短进程吗?

java - 如何删除字符串中/*和*/表示的注释?