0
我通過wsimport從遠程wsdl生成了存根文件,並創建了獨立客戶端。現在,當我運行的客戶端,所產生的HTTP請求是這樣的:JAX WS未生成正確的HTTP請求
HTTP標頭:
---[HTTP request - http://www.transportdirect.info/EnhancedExposedServices/CarJourneyPlannerSynchronous/v1/CarJourneyPlannerSynchronousService.asmx]---
Content-type: text/xml;charset="utf-8"
Soapaction: "http://www.transportdirect.info/TransportDirect.EnhancedExposedServices.CarJourneyPlannerSynchronous.V1/GetGridReference"
Accept: text/xml, multipart/related, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
HTTP正文:
<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>USERNAME</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">PASSWORD</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</S:Header>
<S:Body>
<GetGridReference xmlns="http://www.transportdirect.info/TransportDirect.EnhancedExposedServices.CarJourneyPlannerSynchronous.V1">
<transactionId>bfe2ccbe-9197-4992-9073-cd3a3c0e5c47</transactionId>
<locationType>Postcode</locationType>
<locationValue>W11</locationValue>
</GetGridReference>
</S:Body>
</S:Envelope>
現在,SOAP信封的部分是完全沒有問題因爲我已經使用SOAP工具對其進行了測試並獲得了正確的輸出。但上面的HTTP請求總是給我
---[HTTP response - http://www.transportdirect.info/EnhancedExposedServices/CarJourneyPlannerSynchronous/v1/CarJourneyPl
annerSynchronousService.asmx - 500]---
null: HTTP/1.1 500 Internal Server Error
Cache-control: private
X-ua-compatible: IE=EmulateIE7
Content-type: text/html; charset=utf-8
Content-length: 7424
Connection: close
X-powered-by: ASP.NET
後面跟着大量的html標籤,描述了一些錯誤。
我的Java客戶端代碼如下 -
CarJourneyPlannerSynchronousService service = new CarJourneyPlannerSynchronousService();
port = service.getCarJourneyPlannerSynchronousServiceSoap();
port.getGridReference(transactionId, "bla-bla", "bla-bla");
能否請你告訴我我在這裏失蹤?請讓我知道,如果你想看到更多的代碼。上線
感謝Miljen。你的建議幫助我嗅探周圍。目標HTTP請求URL是錯誤的。現在,這些都是wsimport生成的java文件,除了我上面的Java代碼之外 - 代碼中的哪個位置可以更改服務URL? – somakd
您可以通過(至少)兩種方式更改服務URL,看看這個很好的答案:http://stackoverflow.com/questions/2490737/how-to-change-webservice-url-endpoint –
謝謝你許多。這工作! – somakd