似乎不知道在我的WebService类中正确使用wsgen的位置(什么目录 - 源或类)...
创建基于WebService的示例文档文字:
package hello;
import javax.jws.WebService;
@WebService
public class HelloWorld {
public void sayHello() {
System.out.println("Welcome to JAX-WS 2!");
}
}
Run Code Online (Sandbox Code Playgroud)
像这样创建了发布者:
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());
}
}
Run Code Online (Sandbox Code Playgroud)
使用Eclipse Helios,我自动将这两个文件构建为相应类目录下的*.classes.
所以,从文件系统来看,我的项目看起来像这样:
/code/jws_sample
|
src
|
hello
|
HelloWorld.java
Publisher.java
|
classes
|
HelloWorld.class
Publisher.class
Run Code Online (Sandbox Code Playgroud)
我会在哪个目录中运行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
Run Code Online (Sandbox Code Playgroud)
它确实在浏览器中向我显示了WSDL,当我尝试从$ MyProject/classes发出wsgen命令时,它实际上创建了一个带有SayHelloResponse.class文件而不是SayHelloResponse.java文件的jaxws文件夹?
感谢您抽出时间来阅读.
看起来你必须首先将文件编译成类文件,然后将它们提供给wsgen.
classpath <path> specify where to find input **class files**
Run Code Online (Sandbox Code Playgroud)
我错了,但我相信我过去也必须这样做.
谢谢,
Jeffrey Kevin Pry
| 归档时间: |
|
| 查看次数: |
24011 次 |
| 最近记录: |