Reputation: 10098
I'm calling a web service from a jax-ws java client, when i recieve a response i get an exception saying that the content-type isn't supported,
the exception trace is as follows.
com.sun.xml.ws.server.UnsupportedMediaException: Unsupported Content-Type: application/soap+xml Supported ones are: [text/xml]
at com.sun.xml.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:295)
at com.sun.xml.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:129)
at com.sun.xml.ws.encoding.SOAPBindingCodec.decode(SOAPBindingCodec.java:360)
at com.sun.xml.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:187)
at com.sun.xml.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:94)
at com.sun.xml.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:116)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:598)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:557)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:542)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:439)
at com.sun.xml.ws.client.Stub.process(Stub.java:222)
at com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:135)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:109)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:89)
at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:118)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
I have checked the headers in the soap request, it shows that the acceptable content-types are html/xml, text/jpg etc.. but not application/xml+soap.
when testing with SoapUI, things work perfectly.
we are using SOAP v1.1.. but (clearly) the client is using SOAP 1.2.. is there a way for us to parse the response?
Upvotes: 2
Views: 16931
Reputation: 414
Sorry for re-opening such an old question.
I just want to add some more datail about WHY it should not be possible (at least in theory) to accept other MIMEs other than text/xml
with a SOAP v1.1 server.
The documentation about SOAP v1.1 on W3C (§6) states that
HTTP applications MUST use the media type "text/xml" according to RFC 2376 when including SOAP entity bodies in HTTP messages.
While if we look at the most recent documentation of SOAP v1.2 (§1.3) what we find is:
The media type "application/soap+xml" SHOULD be used for XML 1.0 serializations of the SOAP message infoset
I think that a nice try could be to add an equivalent service implementing SOAP v1.2 and gradually switch to this new one. In the vast majority of cases the switch would "just work"
Upvotes: 0
Reputation: 23
You could remove binding="http://java.sun.com/xml/ns/jaxws/2003/05/soap/bindings/HTTP/"
from endpoint definition in the sun-jaxws.xml
.
Upvotes: 1
Reputation:
if you are using maven as a build tool, be sure to check your maven goal has XSoap1.2 as a protocol.. we had a similar issue we couldn't figure it out for weeks..
hope this helps you...
Upvotes: 3
Reputation: 14187
Extrated from someone else
The @BindingType annotation is only necessary as we're using SOAP v1.2.
If you forget this line and you've specified SOAP v1.2 in your WSDL you'll
receive a runtime exception about the wrong content-type header as follows:
SEVERE: Unsupported Content-Type: application/soap+xml;
charset=UTF-8 Supported ones are: [text/xml]
com.sun.xml.ws.server.UnsupportedMediaException: Unsupported Content-Type:
application/soap+xml; charset=UTF-8 Supported ones are: [text/xml]
Maybe you are trying to use the wrong SOAP version.
Glassfish also has a SOAP 1.2 page to help.
Upvotes: 2