![](/img/trans.png)
[英]Exception in thread “main” com.sun.xml.internal.ws.client.ClientTransportException: The server sent HTTP status code 502: Proxy Error
[英]Connecting to webservice results in com.sun.xml.internal.ws.client.ClientTransportException: The server sent HTTP status code 200: OK
我使用 sun-jaxws 制作了 wsdl。 我在Netbeanse中創建了web服務客戶端,並成功調用了wsdl web服務。 然后我將我的 nginx 服務器配置為通過 https 訪問 web 服務。 When I call service over https I get error com.sun.xml.internal.ws.client.ClientTransportException: The server sent HTTP status code 200: OK
我的 wsdl 可通過地址https://somesite.com/mywsdl/?wsdl
。 在 wsdl 內部,我看到了這樣的服務位置:
<service name="GenericService"> <port name="GenericServicePort" binding="tns:GenericServicePortBinding"> <soap:address location="https://somesite.com:443/mywsdl"/> </port> </service>
我不知道問題是在我的 nginx 配置中,還是在我的 jaxws 中。
問題在於我網址中的額外斜線。 我將網址從https://somesite.com/mywsdl/?wsdl
更改為https://somesite.com/mywsdl?wsdl
,問題就消失了。
您通常會收到ClientTransportException: The server sent HTTP status code 200: OK
當您的客戶端連接到的 SOAP 服務器發送content-type
text/html
的響應時。
We can see that in the following code: com.sun.xml.ws.transport.http.client.HttpTransportPipe
(from jaxws-rt
, or the same class from the internal
JRE package com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe
)
if (contentType != null && contentType.contains("text/html") && binding instanceof SOAPBinding) {
throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(con.statusCode, con.statusMessage));
}
通常,當您從 SOAP 服務器收到答案時,您應該得到以下內容類型作為響應:
text/xml
application/soap+xml
當響應標記為 HTML 時,它是以下問題之一:
SOAPFault
SOAPFault
無論如何,如果您嘗試對此進行調試,您的第一步應該是在您的 SOAP 客戶端上啟用以下 vmoptions:
-Dcom.sun.xml.ws.transport.http.client.HttpTransportPipe.dump=TRUE
-Dcom.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.dump=TRUE
-Dcom.sun.xml.ws.transport.http.HttpAdapter.dump=TRUE
-Dcom.sun.xml.internal.ws.transport.http.HttpAdapter.dump=TRUE
-Dcom.sun.xml.internal.ws.transport.http.HttpAdapter.dumpTreshold=999999
這些將轉儲/記錄整個 HTTP 請求 + 響應(標頭和正文)。 有了這個,您可以根據端點和(可能的)HTML 頁面正文來分析錯誤的確切位置。 可能是 HTML,因為它也很可能是一個正常的 SOAPFault XML,只是內容類型錯誤 header(如果服務器未正確實現)。
有關此類 SOAP 問題的更多信息,您還可以閱讀以下問題:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.