How to avoid "505: HTTP Version not supported" error?

moxn picture moxn · Aug 8, 2010 · Viewed 14.9k times · Source

I am trying to use the Bing SOAP API for a simple search request. But now that I finally figured out how to send the request using JAX-WS, I am stuck again. I get the reply com.sun.xml.internal.ws.client.ClientTransportException: The server sent HTTP status code 505: HTTP Version not supported when I send the request. Can anyone help me out?

I am using dynamic invocation with JAX-WS 2.0, if that makes any difference.

Dispatch<SOAPMessage> dispatch = service.createDispatch(
    portName, SOAPMessage.class, Service.Mode.MESSAGE);
MessageFactory messageFactory = ((SOAPBinding) dispatch.getBinding())
    .getMessageFactory();
SOAPMessage request = messageFactory.createMessage();
// Add content to the request
SOAPMessage response = dispatch.invoke(request);

Wireshark tells me, that the request header contains POST /soap.asmx HTTP/1.1 and the reply comes back also with an HTTP/1.1 versioning. Doesn't this mean, it's alright?

Thanks, moxn

UPDATE: It's not a JAX-WS specific error. I implemented the communication via Commons HTTPClient and still get the same 505.

Following the headers from the HTTPClient request:

Content-Length: 435
Content-Type: text/xml
Host: api.bing.net:80
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.0.1 (java 1.5)
Expect: 100-Continue

UPDATE: It also doesn't work with HTTP/1.0 btw...

Answer

Chris Voon picture Chris Voon · Nov 20, 2015

Have you tried adding the following to app.config or web.config?

<configuration>
  <system.net>
    <settings>
      <servicePointManager expect100Continue="false" />
    </settings>
  </system.net>
</configuration>

Obviously sending the Expect: 100-continue in request header causes the “505: HTTP Version not supported” error to be thrown.

Expect 100-continue