似乎不知道在哪里(哪些目录源或类)对我的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。hello.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 <path>
-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文件夹?
感谢您抽出时间来阅读这篇文章。
发布于 2011-06-24 04:33:00
看起来您必须首先将这些文件编译成类文件,然后将它们提供给wsgen。
classpath <path> specify where to find input **class files**我可能是错的,但我相信我在过去也必须这样做。
谢谢,
Jeffrey Kevin Pry
发布于 2011-07-02 02:09:33
您需要启用'-keep‘,并且可以选择指定'-s /path/ to /src’来保存JAXWS生成的文件。由于这些文件是生成的文件,因此最佳实践通常会引导您不要保留这些文件,而只生成它们以进行打包。保留和编辑这些文件的缺点是,如果您重新生成这些文件,您所做的更改可能会丢失。
例如,我有一个在Maven项目中定义的JAX-WS端点,每次打包服务时都会调用WSGEN目标。
发布于 2012-02-27 14:39:24
您需要对sei类文件而不是源文件运行wsgen。cd从src目录中取出并放入类目录,然后对HelloWorld.class执行wsgen命令。
https://stackoverflow.com/questions/6460258
复制相似问题