![](/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.