Jax-ws: setting up Content-Type of request

Recently, I am trying to use .net WCF support team using JAX-WS. Due to the security of the service, I have to set the user authorization of the HTTP header with some signature in it. I solved this by doing something like this:

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

However, when I call the service, I get an exception:

 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 for my request in the service there may be a requirement to be a text / text type of content. How to install it? I searched and read the documentation a lot, but I seem to be unable to understand. Of course, the exception may be something other than the Content-Type parameter (since I read that jax-ws uses text / xml by default), but I'm not sure.

Thanks in advance!

+6
java web-services jax-ws wcf client
source share
1 answer

As an answer, you return the content type text / html.

In most cases, when I get this error, the server sends an html page with an error.

If you have a way to record a response, you should know exactly what the problem is.

+8
source share

All Articles