0

メッセージ形式とデータ構造が既に定義されているレガシーアプリケーションと統合しようとしています。

ここで、Java 6 を使用して、次のコードで Web サービスを公開します。

Endpoint.publish(urlString, 新しい NotificationListener());

私の NotificationListener サービスには 1 つのメソッドが含まれており、その定義は次のとおりです。

@WebService
public class NotificationListener {

        @WebMethod(action="notifyStatus111")
         @WebResult(name="NotificationResponse")
      public NotificationResponse notifyStatus1(@WebParam(name="Notification") Notification Notification)
      {
            return new NotificationResponse();
      }

wsgen コマンドを使用して、次の ant コマンドを介して Web サービスのスタブを生成します。

<project default="wsgen">
 <target name="wsgen" >
  <exec executable="wsgen">
   <arg line="-cp ./bin -keep -s ./src -d ./bin com.xyz.listener.NotificationListener"/>
  </exec>
 </target>
</project>

ここでの問題は、生成されたスタブと wsdl が、入力オブジェクトと出力オブジェクトに対してメソッド名を持つラッパーを作成することです。

たとえば、生成される id の定義は次のとおりです。

@XmlRootElement(name = "notifyStatus1")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "notifyStatus1")
public class NotifyStatus1 {

    @XmlElement(name = "notification", namespace = "")
    private com.xyz.listener.notifications.Notification notification;

}

NotifyStatus1 スタブ内に埋め込まれている通知オブジェクト。

ただし、従来のアプリケーションは同じことを期待していません。代わりに、通知オブジェクトが直接のルート要素であることを期待しています。

ラッパーと同じようにラップするのではなく、通知をルートとして定義し、それに応じて定義を公開する方法もあります。

ポイントヘルプは大歓迎です。

4

2 に答える 2

0

迅速なフィードバックと指針をありがとうございます。wsgenコマンドでスタブクラスを生成しないことで提案された方法を試し、Webサービスを直接公開しました。

それでも、生成された wsdl を介して検証した出力は同じです。以下は、生成された wsdl のスニペットです。

<portType name="NotificationListener">
     <operation name="notifyStatus1">
            <input message="tns:notifyStatus1"/>
             <output message="tns:notifyStatus1Response"/>
      </operation>
</porttype> 
于 2013-07-25T17:18:03.340 に答える