我嘗試連接到Yahoo webservice。我通過axis2生成類。我現在面臨的問題是,web服務需要在標題中使用特定的鍵值對,我絕對無法這樣做。我搜索了網絡,發現了不同的可能性 - 它們都不適合我。最有希望的是幾乎在this page末尾的帖子,Claude Coulombe被要求改變生成的存根的代碼,但是這也失敗了。任何人都可以告訴我一個方法如何解決這個問題?如何將http頭添加到java中的soaprequest中
編輯
使用選項建議的方式產生了以下異常:
Exception in thread "main" org.apache.axis2.AxisFault: Address information does not exist in the Endpoint Reference (EPR).The system cannot infer the transport mechanism.
這裏是我的代碼:
val stub = new IndexToolsApiServiceStub("https://api.web.analytics.yahoo.com/IndexTools/services/IndexToolsApiV3")
val client = stub._getServiceClient
val options = new Options
val list = new ArrayList[Header]()
val header = new Header
header.setName("YWA_API_TOKEN")
header.setValue("NOTtheREALvalue")
list.add(header)
options.setProperty(HTTPConstants.HTTP_HEADERS, list)
client.setOptions(options)
stub._setServiceClient(client)
我假設你的問題是關於HTTP頭(不是HTML)。您可能要更正錯字... –
不好意思,你說得對。 –