0

Grails プロジェクトで ws-client を使用して Web サービスを呼び出しています。

大丈夫ですが、WSDL からエンドポイントを読み取っています。

実行時にエンドポイントを変更するには?

def proxy = new WSClient(wsdlURL, Thread.currentThread().getContextClassLoader());
proxy.setEndpoint(''); // this doesn't exists, ERROR!

ありがとう!

注:BindingProvider.ENDPOINT_ADDRESS_PROPERTYこれを解決するために使用する必要がありますか?

4

2 に答える 2

1

次のコードを実行して、エンドポイント アドレスを変更できます。

// getter method for the wrapped client class
WSClient.metaClass.getCxfClient = { ->
    delegate.client
}
// init ws client
proxy = new WSClient(wsdlURL, this.class.classLoader)
proxy.initialize()
// get client instance
def cxfClient = proxy.cxfClient
// create new endpoint url
URL newUrl = new URL("http://edu-02:8080/educenter/services/sync")
// assign new created url to the client
cxfClient.getConduit().getTarget().getAddress().setValue(newUrl.toExternalForm());
于 2011-07-26T05:58:48.960 に答える
0

メソッドでカプセル化された回答であるhitty5回答を使用します。

// class with proxy attribute instanciated
def setEndpoint(String endpoint){
    String url = new URL(endpoint).toExternalForm()
    this.proxy.client.conduit.target.address.setValue(url)
}

追加:タイムアウトを設定するには、次を使用します。

proxy.client.conduit.clientSidePolicy.setReceiveTimeout(999)
proxy.client.conduit.clientSidePolicy.setConnectionTimeout(999)
于 2011-07-26T14:28:26.490 に答える