Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unsupported Content-Type: text/html; charset=UTF-8 Supported ones are: [text/xml]

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!

like image 615
save_ole Avatar asked Aug 29 '12 02:08

save_ole


2 Answers

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.

like image 117
robinwen Avatar answered Oct 06 '22 06:10

robinwen


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.

like image 21
Nicolás Piquerez Avatar answered Oct 06 '22 06:10

Nicolás Piquerez