3

CXFを使用して、リモートWebサービスに接続するためのクライアントを生成しています。Webサービスまたはwsdl定義を制御することはできません。

Webサービスのwsdlは、ローカルホストへのいくつかの参照を作成します。次に例を示します。

<soap12:address location="http://localhost:8002/request" />
<wsa10:EndPointReference>
    <wsa10:Address>http://localhost:8002/request</wsa10:Address>
</wsa10:EndPointReference>

リモートwsdlをポイントしながら、wsdl2javamavenゴールを使用してクライアントを生成しようとしています。

...
<wsdlOptions>
<wsdlOption>
<wsdl>http://remotehost:8002/?wsdl</wsdl>
<wsdlOption>
<wsdlOptions>
...

クライアントを構築しようとすると、ローカルホストへの参照が原因で目標が失敗します。

org.apache.cxf.wsd11.WSDLRuntimeException: Fail to create wsdl definition from :       http://remotehost:8002/?wsdl [ERROR] caused by : WSDLException (at  
/wsdldefinitions/wsdl:import) faultCode=PARSER_ERROR: Problem parsing  
'http://localhost:8002/?wsdl=wsdl0'.: java.net.ConnectionException: Connection refused: connect

ローカルホスト参照がwsdlホストに関連していることをCXFに理解させ、クライアントを生成するときにそれらを適切なホスト名に自動的に置き換える方法はありますか?

wsdlをローカルファイルにコピーし、ローカルホスト参照を適切なホスト名に手動で置き換えることで、クライアントを生成することができました。ただし、クライアントはローカルファイルではなくリモートのwsdl定義から生成する必要があります。これを達成する方法を知っている人はいますか?私は現在cxfバージョン2.6.0を使用しています

回答をよろしくお願いします。

(実際のサービス名をremotehostなどの一般的な名前に置き換えました)

4

1 に答える 1

1

You want to make CXF understand that the localhost references are relevant to the wsdl host but this is not something that should be understood by any tool, since the WSDL can import other WSDL from any location, and this could be in some cases the correct reference. Simply it is not in your case, it is configuration error from the site you want to connect to.

I understand you're giving the URL to WSDL as an argument to the tool making proxy dynamically, so you can't just download it and change references.

The workaround I suggest is to write simple proxy, a servlet that would connect to remote URL (given as argument) and would return WSDL, changing localhost references to the correct ones. And you would give the URL of this servlet as argument to your proxy factory. It isn't nice, but the only nice solution is that the provider fixes its own WSDL.

于 2012-05-23T10:43:30.210 に答える