Unsupported Content-Type: text/html; charset=UTF-8 Supported ones are: [text/xml]
Solution 1
Add the following code in the head of the class:
@BindingType("http://java.sun.com/xml/ns/jaxws/2003/05/soap/bindings/HTTP/")
Then restart your server.
Solution 2
This error has happend to me and the reason was that the call to the webservices was made to an invalid host, so the web server responds with a http error message instead of an xml soap message.
Solution 3
I my case, same error, but different reason:
The Port wasn't specified in the wsdl, which the Server gave back to the Java Service "Generator". Therefore the Webserver answered the SOAP call, with a Homepage, which of course wasn't text/XML but text /html.
Adding the Port to the wsdl solved the Problem.
save_ole
Updated on October 16, 2020Comments
-
save_ole over 3 years
I'm attempting to use the web service to retrieve data from server. I follow the tutorial specified in http://googcloudlabs.appspot.com/codelabexercise5.html, of course I've modified the original code to satisfied my demands.
Now I'm getting an error like this: Unsupported Content-Type: text/html; charset=UTF-8 Supported ones are: [text/xml]
To see the full error, I write a new error function when getting data:
var errorFn = function(e){ for(var p in e){ alert(e[p]); } } var successFn = function(resp){ var data=''; if(resp){ //getting the data from the response object data=resp.data; } //Some other code here... } getData("/entity",null,successFn,errorFn);
And the browser alert the error object:
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> <title>Error 500 Unsupported Content-Type: text/html; charset=UTF-8 Supported ones are: [text/xml]</title> </head> <body><h2>HTTP ERROR 500</h2> <p>Problem accessing /vehicle. Reason: <pre> Unsupported Content-Type: text/html; charset=UTF-8 Supported ones are: [text/xml]</pre></p><h3>Caused by:</h3><pre>com.sun.xml.internal.ws.server.UnsupportedMediaException: Unsupported Content-Type: text/html; charset=UTF-8 Supported ones are: [text/xml] at com.sun.xml.internal.ws.encoding.StreamSOAPCodec.decode(Unknown Source) at com.sun.xml.internal.ws.encoding.StreamSOAPCodec.decode(Unknown Source) at com.sun.xml.internal.ws.encoding.SOAPBindingCodec.decode(Unknown Source) at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.process(Unknown Source) at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.processRequest(Unknown Source) at com.sun.xml.internal.ws.transport.DeferredTransportPipe.processRequest(Unknown Source) at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Unknown Source) at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Unknown Source) at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Unknown Source) at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Unknown Source) at com.sun.xml.internal.ws.client.Stub.process(Unknown Source) at com.sun.xml.internal.ws.client.sei.SEIStub.doProcess(Unknown Source) at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source) at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source) at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(Unknown Source) at $Proxy32.getAllVehicles(Unknown Source) at com.google.appengine.codelab.soap.client.VehicleServlet.doGet(VehicleServlet.java:52) at javax.servlet.http.HttpServlet.service(HttpServlet.java:617) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166) at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:35) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:60) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at com.google.appengine.tools.development.BackendServersFilter.doFilter(BackendServersFilter.java:97) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388) at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765) at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418) at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:94) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:370) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) at org.mortbay.jetty.Server.handle(Server.java:326) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542) at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:547) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404) at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409) at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582) </pre> <hr /><i><small>Powered by Jetty://</small></i><br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> </body> </html>
Somebody help me with this problem ??
Thank in advance!
-
save_ole over 11 yearsYes I think so @Peter but where can I config the HTTP requests, in the servlet class or somewhere in /war directory??
-
instanceOfObject over 10 years@Peter Where do we need to specify the Content-Type header? HTTP Request is not with me. We just call an exposed method from wsdl. I am sure I am missing something. Please guide.
-
Mohammad Banisaeid almost 10 yearsJust to add more info to this answer, this annotation makes sure SOAP 1.2 is used instead of SOAP 1.1. jax-ws.java.net/2.1.5/docs/soap12.html