4

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

Angelo Fuchs
  • 9,825
  • 1
  • 35
  • 72
moxn
  • 1,790
  • 1
  • 15
  • 34
  • 1
    Can you show the full request you are trying to send (URL and the complete post from your Wireshark capture)? Sometimes space in a URL or post can cause this issue. i.e. the error might be pointing a different problem than what you think it is.. – gbvb Feb 08 '11 at 22:16
  • @gbvb Hey, thanks for inquiring. I completely forgot about this question. I already got it figured out (see answer below). – moxn Feb 12 '11 at 11:12

2 Answers2

2

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

Chris Voon
  • 1,974
  • 2
  • 18
  • 11
1

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.

moxn
  • 1,790
  • 1
  • 15
  • 34