Đừng dường như không biết nơi (những gì thư mục - nguồn hoặc lớp) để đúng cách sử dụng wsgen chống lại lớp WebService tôi ...Nơi sử dụng wsgen?
Tạo một tài liệu mẫu đen dựa WebService:
package hello;
import javax.jws.WebService;
@WebService
public class HelloWorld {
public void sayHello() {
System.out.println("Welcome to JAX-WS 2!");
}
}
Created nhà xuất bản như thế này:
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());
}
}
Sử dụng Eclipse Helios, tôi tự động tạo cả hai tệp này dưới dạng * .classes bên dưới thư mục lớp tương ứng.
Vì vậy, từ hệ thống tập tin, dự án của tôi trông như thế này:
/code/jws_sample
|
src
|
hello
|
HelloWorld.java
Publisher.java
|
classes
|
HelloWorld.class
Publisher.class
Trong đó thư mục tôi sẽ chạy wsgen?
Khi tôi thử bên trong:
/code/jaxws_sample/src/wsgen -cp. hello.HelloWorld
đã nhận:
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
Nó thực sự không chỉ cho tôi các WSDL trong trình duyệt và cũng có khi tôi đã cố gắng để thực hiện lệnh wsgen từ $ MyProject/classes nó thực sự đã tạo ra một thư mục jaxws với Tệp SayHelloResponse.class nhưng không phải tệp SayHelloResponse.java?
Cảm ơn bạn đã dành thời gian đọc nội dung này.
Tôi đã làm điều đó ... Eclipse đã tạo ra các lớp thư mục tương ứng và làm như sau: $ MyProject/classes/wsgen -cp. hello.HelloWorld làm việc, nhưng nó đặt các stubs được tạo ra bên trong thư mục classes. Làm thế nào người ta có thể sử dụng -d để đặt chúng bên trong thư mục src? –