Announcement Announcement Module
Collapse
No announcement yet.
javax.xml.soap.SOAPException: Unsupported Content-Type: application/x-www-form-urlenc Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • javax.xml.soap.SOAPException: Unsupported Content-Type: application/x-www-form-urlenc

    Hi,

    I am getting the following error when invoking the (web)service from a web-application (both client and service are running on same server), where, it works beautifully if the client is a stand alone java app. This is on weblogic 8.1.

    =================
    org.springframework.ws.soap.SoapMessageCreationExc eption: Could not create message from InputStream: Unsupported Content-Type: application/x-www-form-urlencoded; nested exception is javax.xml.soap.SOAPException: Unsupported Content-Type: application/x-www-form-urlencoded
    Caused by:
    javax.xml.soap.SOAPException: Unsupported Content-Type: application/x-www-form-urlencoded
    at weblogic.webservice.core.soap.SOAPMessageImpl.<ini t>(SOAPMessageImpl.java:163)
    at weblogic.webservice.core.soap.MessageFactoryImpl.c reateMessage(MessageFactoryImpl.java:30)
    at org.springframework.ws.soap.saaj.SaajSoapMessageFa ctory.createWebServiceMessage(SaajSoapMessageFacto ry.java:163)
    at org.springframework.ws.transport.AbstractWebServic eConnection.receive(AbstractWebServiceConnection.j ava:52)
    at org.springframework.ws.transport.support.WebServic eMessageReceiverObjectSupport.handleConnection(Web ServiceMessageReceiverObjectSupport.java:84)
    at org.springframework.ws.transport.http.WebServiceMe ssageReceiverHandlerAdapter.handle(WebServiceMessa geReceiverHandlerAdapter.java:56)
    at org.springframework.ws.transport.http.MessageDispa tcherServlet.doService(MessageDispatcherServlet.ja va:157)
    at org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:396)
    at org.springframework.web.servlet.FrameworkServlet.d oPost(FrameworkServlet.java:360)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:760)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:853)
    at weblogic.servlet.internal.ServletStubImpl$ServletI nvocationAction.run(ServletStubImpl.java:1072)
    at weblogic.servlet.internal.ServletStubImpl.invokeSe rvlet(ServletStubImpl.java:465)
    at weblogic.servlet.internal.ServletStubImpl.invokeSe rvlet(ServletStubImpl.java:348)
    at weblogic.servlet.internal.WebAppServletContext$Ser vletInvocationAction.run(WebAppServletContext.java :6981)
    at weblogic.security.acl.internal.AuthenticatedSubjec t.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(Se curityManager.java:121)
    at weblogic.servlet.internal.WebAppServletContext.inv okeServlet(WebAppServletContext.java:3892)
    at weblogic.servlet.internal.ServletRequestImpl.execu te(ServletRequestImpl.java:2766)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThrea d.java:224)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.ja va:183)

    ================

    Thanks in advance for any help

  • #2
    At the end of the exception stack trace, I have the following message
    -------------------
    Caused by: org.springframework.ws.soap.SoapMessageCreationExc eption: Could not create message from InputStream: Unsupported Content-Type: text/html; nested exception is javax.xml.soap.SOAPException: Unsupported Content-Type: text/html
    at org.springframework.ws.soap.saaj.SaajSoapMessageFa ctory.createWebServiceMessage(SaajSoapMessageFacto ry.java:179)
    at org.springframework.ws.transport.AbstractWebServic eConnection.receive(AbstractWebServiceConnection.j ava:52)
    at org.springframework.ws.client.core.WebServiceTempl ate.sendAndReceive(WebServiceTemplate.java:408)
    at org.springframework.ws.client.core.WebServiceTempl ate.marshalSendAndReceive(WebServiceTemplate.java: 265)
    at org.springframework.ws.client.core.WebServiceTempl ate.marshalSendAndReceive(WebServiceTemplate.java: 253)
    at org.springframework.ws.client.core.WebServiceTempl ate.marshalSendAndReceive(WebServiceTemplate.java: 249)
    at com.dadesk.integration.core.task.IntegrationTaskRe questorImpl.requestTaskAsWebService(IntegrationTas kRequestorImpl.java:243)
    at com.dadesk.integration.core.task.IntegrationTaskRe questorImpl.requestIntegrationTask(IntegrationTask RequestorImpl.java:76)
    at com.dadesk.integration.core.task.impl.dadesk.DADes kValueObjectUtilTask.fetchValueObject(DADeskValueO bjectUtilTask.java:323)
    at com.dadesk.integration.core.task.impl.dadesk.DADes kValueObjectUtilTask.performTask(DADeskValueObject UtilTask.java:148)
    at com.dadesk.integration.core.task.SimpleTaskRunner. runTask(SimpleTaskRunner.java:59)
    ... 53 more
    Caused by: javax.xml.soap.SOAPException: Unsupported Content-Type: text/html
    at weblogic.webservice.core.soap.SOAPMessageImpl.<ini t>(SOAPMessageImpl.java:163)
    at weblogic.webservice.core.soap.MessageFactoryImpl.c reateMessage(MessageFactoryImpl.java:30)
    at org.springframework.ws.soap.saaj.SaajSoapMessageFa ctory.createWebServiceMessage(SaajSoapMessageFacto ry.java:163)
    ... 63 more
    --------------------------------

    Another thing I have noticed is that, when I call from a stand alone client, the HTTP version is 1.1 (which works fine) and if it is from a servlet, it is 1.0 (fails).

    What I guess is that, for some reason, when it is invoked from servlet, the content-type is automatically assigned as text/html, which causes the error.

    Comment


    • #3
      how can you resolve this issue? could you please send me the solution

      Comment


      • #4
        Dude,

        I could not resolve this issue yet.

        It looks like, it sets a header-value, content-type=text/html. No I dea about how to fix it.

        This is on weblogic 8.1. I am using XMLBeans Marshaller. And this happens only when I call the service from a servlet. From a stand alone app, it works fine.

        Comment


        • #5
          My understanding is, the issue is for some unknown reason, if the client is invoked from a servlet, the soap mime-header, content type is set to text/html, instead of text/xml.

          Could somebody tell me how can I set the proper content-type in the header ?

          I am calling the WebServicetemplate.marshalSendAndReceive(serviceUR I, xmlRequestDoc);

          Thanks.

          Comment


          • #6
            It seems like the HttpUrlConnection in weblogic changes the content-type from 'text/xml' to 'application/x-www-form-urlencoded'. I have no idea how to disable that.

            As a workaround, you can use the CommonsHttpMessageSender, which does work. Here is a little servlet which shows this:

            Code:
            public class MyServlet extends HttpServlet {
            
                private static final org.apache.commons.logging.Log logger =
                        org.apache.commons.logging.LogFactory.getLog(MyServlet.class);
            
                protected void doGet(HttpServletRequest httpServletRequest, final HttpServletResponse httpServletResponse)
                        throws ServletException, IOException {
                    WebServiceTemplate template = new WebServiceTemplate();
                    template.setMessageSender(new CommonsHttpMessageSender());
                    Source source = new StringSource(
                            "<echoRequest xmlns=\"http://www.springframework.org/spring-ws/samples/echo\">Hello</echoRequest>");
                    Result result = new StringResult();
                    template.setDefaultUri("http://localhost:8090/echo/services");
                    template.sendSourceAndReceiveToResult(source, result);
                    logger.info(result.toString());
                }
            }

            Comment


            • #7
              It works

              WOWW.. It works.

              And thanks a lot for this fix.

              Actually, I was planning to go with weblogic web-services for the client API.

              This fix saves me a lot.

              Thank again, Arjen.

              Comment


              • #8
                Webservices client

                Hi,

                i have written the client application exactly what you have given sample code and included all the dependancy jar files in my lib folder, when i run the application i am getting one error,

                Error 500--Internal Server Error
                java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpClient
                at org.springframework.ws.transport.http.CommonsHttpM essageSender.(CommonsHttpMessageSender.java:68)
                at stream.jms.client.StreamWebServiceClient.doGet(Str eamWebServiceClient.java:23)
                at javax.servlet.http.HttpServlet.service(HttpServlet .java:743)
                at javax.servlet.http.HttpServlet.service(HttpServlet .java:856)
                at weblogic.servlet.internal.StubSecurityHelper$Servl etServiceAction.run(StubSecurityHelper.java:225)
                at weblogic.servlet.internal.StubSecurityHelper.invok eServlet(StubSecurityHelper.java:127)
                at weblogic.servlet.internal.ServletStubImpl.execute( ServletStubImpl.java:283)
                at weblogic.servlet.internal.ServletStubImpl.execute( ServletStubImpl.java:175)
                at weblogic.servlet.internal.WebAppServletContext$Ser vletInvocationAction.run(WebAppServletContext.java :3214)
                at weblogic.security.acl.internal.AuthenticatedSubjec t.doAs(AuthenticatedSubject.java:321)
                at weblogic.security.service.SecurityManager.runAs(Se curityManager.java:121)
                at weblogic.servlet.internal.WebAppServletContext.sec uredExecute(WebAppServletContext.java:1983)
                at weblogic.servlet.internal.WebAppServletContext.exe cute(WebAppServletContext.java:1890)
                at weblogic.servlet.internal.ServletRequestImpl.run(S ervletRequestImpl.java:1344)
                at weblogic.work.ExecuteThread.execute(ExecuteThread. java:209)
                at weblogic.work.ExecuteThread.run(ExecuteThread.java :181)


                Even though i have included commons-httpclient-3.0.1.jar file for dependancy check, still getting the same error. Can you please advise on this.

                Java code is

                Code:
                protected void doGet(HttpServletRequest httpServletRequest, final HttpServletResponse httpServletResponse)throws ServletException, IOException {
                        WebServiceTemplate template = new WebServiceTemplate();
                        template.setMessageSender(new CommonsHttpMessageSender());
                        System.out.println(getTextSoapMessage());
                        Source source = new StringSource(getTextSoapMessage());
                        Result result = new StringResult();
                        template.setDefaultUri("http://10.253.192.78:7077/StreamServices/streamrequest");
                        template.sendSourceAndReceiveToResult(source, result);
                        System.out.println(result.toString());
                        logger.info(result.toString());
                    }
                Thanks,
                Gangadhar

                Comment

                Working...
                X