views:

2059

answers:

1

Hi.

I've been trying to consume a .net WCF rest service using JAX-WS lately. Due to security of the service, I've have to set a custom HTTP header Authorization with some signature in it. This I've solved by doing something like this:

BindingProvider bp = (BindingProvider) port;
bp.getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS,
                                Collections.singletonMap("Authorization",Collections.singletonList(authHeader)));

However, I get an exception when invoking the service:

com.sun.xml.internal.ws.server.UnsupportedMediaException: Unsupported Content-Type: text/html; charset=UTF-8 Supported ones are: [text/xml]
com.sun.xml.internal.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:284)
com.sun.xml.internal.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:118)
com.sun.xml.internal.ws.encoding.SOAPBindingCodec.decode(SOAPBindingCodec.java:278)
com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:180)
com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:83)
com.sun.xml.internal.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:105)

And it seems to me that there might be a requirement for my request in the service to be text/xml content-type. How do I set this? I've googled a lot, and read some documentation but I can't seem to figure it out. The exception could of course also be something else than the Content-Type setting (since I've read that by default jax-ws uses text/xml) but I'm not sure.

Thanks in advance!

ElChe

A: 

You are getting a text/html content type back as a response.

Most of the time when I have got this error, it has been that the server is sending an html error page.

If you have a way to log the response, you should be able to see exactly what the problem is.

Shiraz Bhaiji
Thanks for reply - so you think the request has actually gone to the wbservice and I get back maybe an error message in the form of html? This might be actually...
El Che