javaweb-servicesjax-wsbing-apihttp-status-code-505

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


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...


Solution

  • In the meantime I got my answer in the Bing developer forum. It seems as if Microsoft is sort of using different semantics for HTTP response codes than most and a 505 can also mean "Something is wrong with your SOAP request". Turns out I did not use the correct namespaces. After fixing them, the request went through just fine.

    Here is the link to the thread in the Bing forum.