メッセージ形式とデータ構造が既に定義されているレガシーアプリケーションと統合しようとしています。
ここで、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 スタブ内に埋め込まれている通知オブジェクト。
ただし、従来のアプリケーションは同じことを期待していません。代わりに、通知オブジェクトが直接のルート要素であることを期待しています。
ラッパーと同じようにラップするのではなく、通知をルートとして定義し、それに応じて定義を公開する方法もあります。
ポイントヘルプは大歓迎です。