简体   繁体   English

连接到 web 服务导致 com.sun.xml.internal.ws.client.ClientTransportException:服务器发送 HTTP 状态码 200

[英]Connecting to webservice results in com.sun.xml.internal.ws.client.ClientTransportException: The server sent HTTP status code 200: OK

I made wsdl using sun-jaxws.我使用 sun-jaxws 制作了 wsdl。 I created web service client in Netbeanse, and successfully called wsdl web service.我在Netbeanse中创建了web服务客户端,并成功调用了wsdl web服务。 Then I configured my nginx server to access web service by https.然后我将我的 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 When I call service over https I get error com.sun.xml.internal.ws.client.ClientTransportException: The server sent HTTP status code 200: OK

My wsdl available by address https://somesite.com/mywsdl/?wsdl .我的 wsdl 可通过地址https://somesite.com/mywsdl/?wsdl Inside the wsdl I see such service location:在 wsdl 内部,我看到了这样的服务位置:

<service name="GenericService"> <port name="GenericServicePort" binding="tns:GenericServicePortBinding"> <soap:address location="https://somesite.com:443/mywsdl"/> </port> </service>

I don't know whether the problem in my nginx configuration, or in my jaxws.我不知道问题是在我的 nginx 配置中,还是在我的 jaxws 中。

The problem was in the extra slash in my url. 问题在于我网址中的额外斜线。 I changed url from https://somesite.com/mywsdl/?wsdl to https://somesite.com/mywsdl?wsdl and the problem disappeared. 我将网址从https://somesite.com/mywsdl/?wsdl更改为https://somesite.com/mywsdl?wsdl ,问题就消失了。

You usually get the ClientTransportException: The server sent HTTP status code 200: OK when the SOAP server, that your client connects to, sends a response with content-type text/html .您通常会收到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 ) 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));
}

Normally when you receive an answer from a SOAP server, you should get the following content types as a response:通常,当您从 SOAP 服务器收到答案时,您应该得到以下内容类型作为响应:

  • SOAP v1.1 uses content-type text/xml SOAP v1.1 使用内容类型text/xml
  • SOAP v1.2 uses content-type application/soap+xml SOAP v1.2 使用内容类型application/soap+xml

When the response is marked as HTML, it's either one of the following issues:当响应标记为 HTML 时,它是以下问题之一:

  • your request is made to the wrong endpoint, and you are presented with some HTML status page (for example SOAPUI also does this on unknown mock endpoints)您的请求发送到错误的端点,并且您会看到一些 HTML 状态页面(例如 SOAPUI 也在未知的模拟端点上执行此操作)
  • your request is invalid for the given endpoint, and the server doesn't send a proper SOAPFault您的请求对给定端点无效,并且服务器未发送正确的SOAPFault
  • your request is valid, but the server is having issues processing it (for example HTTP4xx or HTTP5xx not found/error pages as HTML. But these usually don't have code 200 OK), and doesn't or can't send a proper SOAPFault您的请求有效,但服务器在处理它时遇到问题(例如 HTTP4xx 或 HTTP5xx 未找到/错误页面为 HTML。但这些通常没有代码 200 OK),并且没有或无法发送正确的SOAPFault

In any case if you're trying to debug this, your first step should be to enable the following vmoptions on your SOAP client:无论如何,如果您尝试对此进行调试,您的第一步应该是在您的 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

These will dump/log the entire HTTP request + response (headers and body).这些将转储/记录整个 HTTP 请求 + 响应(标头和正文)。 With this you can analyze where the error exactly is, based on the endpoint and the (possible) HTML page body.有了这个,您可以根据端点和(可能的)HTML 页面正文来分析错误的确切位置。 Possibly HTML, because it can also very well be a normal SOAPFault XML with just the wrong content-type header (if the server is not implemented correctly).可能是 HTML,因为它也很可能是一个正常的 SOAPFault XML,只是内容类型错误 header(如果服务器未正确实现)。

For more information on SOAP issues like this you can also read the following questions:有关此类 SOAP 问题的更多信息,您还可以阅读以下问题:

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 线程“ main” com.sun.xml.internal.ws.client.ClientTransportException中的异常:服务器发送了HTTP状态代码502:代理错误 - Exception in thread “main” com.sun.xml.internal.ws.client.ClientTransportException: The server sent HTTP status code 502: Proxy Error 使用CXF从Java消耗Web服务会导致com.sun.xml.ws.client.ClientTransportException:服务器发送了HTTP状态代码200:确定 - Consuming webservice from java using CXF results in com.sun.xml.ws.client.ClientTransportException: The server sent HTTP status code 200: OK Glassfish抛出com.sun.xml.ws.client.ClientTransportException:服务器发送了HTTP状态代码500:内部服务器错误 - Glassfish throws com.sun.xml.ws.client.ClientTransportException: The server sent HTTP status code 500: Internal Server Error JAX WS com.sun.xml.internal.ws.client.ClientTransportException:HTTP 传输错误:java.net.ConnectException:连接被拒绝 - JAX WS com.sun.xml.internal.ws.client.ClientTransportException: HTTP transport error: java.net.ConnectException: Connection refused com.sun.xml.internal.ws.client.ClientTransportException:HTTP传输错误:java.net.SocketException:连接重置 - com.sun.xml.internal.ws.client.ClientTransportException: HTTP transport error: java.net.SocketException: Connection reset 导入com.sun.xml.internal.ws.client.ClientTransportException,无法读取此导入 - import com.sun.xml.internal.ws.client.ClientTransportException, can't read this import com.sun.xml.ws.client.ClientTransportException:请求需要HTTP身份验证:未经授权 - com.sun.xml.ws.client.ClientTransportException: request requires HTTP authentication: Unauthorized com.sun.xml.ws.client.ClientTransportException:HTTP传输错误:java.lang.ClassCastException - com.sun.xml.ws.client.ClientTransportException: HTTP transport error: java.lang.ClassCastException ClientTransportException:服务器发送了HTTP状态代码302:找到 - ClientTransportException: The server sent HTTP status code 302: Found com.sun.xml.internal.ws.fault.ServerSOAPFaultException:客户端从服务器收到SOAP错误 - com.sun.xml.internal.ws.fault.ServerSOAPFaultException: Client received SOAP Fault from server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM