4

数十のサービス インターフェイスを備えた非常に大きなアプリを開発しています。すべてのサービスについて、wsgen を使用して (jaxws-maven-plugin maven プラグインを使用して) wsdl が生成されます。wsdl では、サービスごとに異なる名前空間が使用されます。

一連の共通 Bean (主に DTO) を共有するサービス インターフェイス。現在、これらの共通クラスの定義はすべての wsdl の XSD で定義されており、多くの情報が複製されており、これがクライアント側で問題を引き起こしています (膨大なコンパイル時間、クラスの非互換性)。

まずschemagenで共通クラスのスキーマを作成しようとしましたが、wsgenに渡すことができませんでした。1 つ (または複数) の一般的な XSD を wsgen に渡し、生成された wsdl でこれらを参照する方法はありますか?

また、カスタム名前空間を指定する @XmlRootElement で共通クラスに注釈を付けようとしました。今回は、wsgen がカスタム名前空間を認識し、すべての wsdl に対してもう 1 つの XSD を生成しましたが、単一の (共通) xsd はどこにも含まれていませんでした。

誰かがこの問題の解決策を教えてくれますか?

4

2 に答える 2

0

同様の問題がありました。

以下の注釈を共通クラスに追加して、wsgen ごとに複数回生成されないようにしました。

@XmlType(namespace = "http://mypackage.mycompany.com/")
public MyClass implements Serializable {
// ... class contents
}
于 2016-04-07T14:04:54.767 に答える
0

You and I have a lot in common. :)

We do a lot of similar things: we have WSDL-first web services and DTOs used throughout our app. However, we define our DTOs with XML schemas so we could add metadata to them which adds code to the generated Java via JAXB plugins. We intended to use these XSD-based DTOs in our web services, but we were forced, by corporate standard, to use some common, corporate XSDs within our web services. It wouldn't have made a difference though - we could have just as easily used our DTO XSDs.

As to your issue, we have XSDs for our DTOs which you don't have. If you did then the only thing you'd need - assuming a Maven multi-module project is how to resolve the schemas across modules. We did this by forking the jaxws maven plugin and adding a CLASSPATH-based catalog schema resolver to it.

I suppose having you create schemas for your DTOs is out of the question? I can't help much beyond that as I've never used the jaxb annotations. Sorry.

于 2011-12-30T01:52:27.817 に答える