[英]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 服务器收到答案时,您应该得到以下内容类型作为响应:
text/xml
text/xml
application/soap+xml
application/soap+xml
When the response is marked as HTML, it's either one of the following issues:当响应标记为 HTML 时,它是以下问题之一:
SOAPFault
SOAPFault
SOAPFault
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.