6

私の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 &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 ファイルを含む jaxws フォルダーが作成されましたが、SayHelloResponse.java ファイルは作成されませんでしたか?

これを読んでいただきありがとうございます。

4

7 に答える 7

7

最初にファイルをクラス ファイルにコンパイルしてから、それらを wsgen にフィードする必要があるようです。

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

私は間違っているかもしれませんが、過去にも同じことをしなければならなかったと思います。

ありがとう、

ジェフリー・ケビン・プライ

于 2011-06-23T20:33:00.213 に答える
1

ソースファイルではなく、seiクラスファイルに対してwsgenを実行する必要があります。srcディレクトリからclassディレクトリにcdし、HelloWorld.classに対してwsgenを実行します。

于 2012-02-27T06:39:23.617 に答える
1

「-keep」を有効にする必要があり、オプションで「-s /path/to/src」を指定して、JAXWS 生成ファイルを保存できます。これらは生成されたファイルであるため、ベスト プラクティスでは通常、ファイルを保持せず、パッケージ化のためにのみ生成するように指示します。ファイルを保持し、おそらく編集することの欠点は、ファイルを再生成すると、変更が失われる可能性があることです。

たとえば、Maven プロジェクトで定義された JAX-WS エンドポイントがあり、サービスがパッケージ化されるたびに WSGEN ゴールが呼び出されます。

于 2011-07-01T18:09:32.987 に答える
0

パッケージが言うように、生成されたクラスファイルが /classes/hello/ にないのは奇妙です...

クラス ファイルが本来 /classes/hello/HelloWorld.class にあることを考えると、classes フォルダーから行う必要があるのは次のとおりです。

wsgen -keep -cp . -d . -s ../src hello.HelloWorld

ちょうどチェックして、私のためにうまくいきました。クラスフォルダーから CMD を呼び出すことを忘れないでください。

于 2013-04-12T21:06:45.907 に答える
0

まず、「hello」ディレクトリの下に「jaxws」ディレクトリを作成する必要があります。

次に、「/code/jws_sample」ディレクトリから次のコマンドを実行してみてください。

wsgen -keep -cp classes/ -s src/ HelloWorld

-sコマンドは、ソース ファイルを配置する場所をジェネレーターに指示します。

これは、私が職場で使用しているスクリプトを使用して作成されたものであり、送信前に実際にテストすることはできませんでした。ただし、これが何らかの方向性を示してくれることを願っています。

于 2012-03-19T12:45:30.703 に答える