Announcement Announcement Module
Collapse
No announcement yet.
Using DomPoxMessageFactory and JAXB Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using DomPoxMessageFactory and JAXB

    Hi, there is an application I'm writing a web service for that needs a response in Plain Old XML (POX). I'm new to Spring WS so I followed the HolidayRequest tutorial and got it to properly receive requests and send responses but the responses were sent with the following format:

    Code:
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
       <SOAP-ENV:Header/>
       <SOAP-ENV:Body>
            <Person>
                <FirstName>John</FirstName>
                <LastName>Smith</LastName>
            </Person>
       </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    The format I need is this:

    Code:
    <Person>
        <FirstName>John</FirstName>
        <LastName>Smith</LastName>
    </Person>
    I was hoping that it would be as simple as adding this line to spring-ws-servlet.xml:
    Code:
    <bean id="messageFactory" class="org.springframework.ws.pox.dom.DomPoxMessageFactory" />
    but the error I get when I test in SoapUI is:
    Code:
    java.lang.IllegalArgumentException: AbstractSoapFaultDefinitionExceptionResolver requires a SoapMessageObject of class [org.springframework.ws.pox.dom.DomPoxMessage] must be an instance of interface org.springframework.ws.soap.SoapMessage
    	at org.springframework.util.Assert.isInstanceOf(Assert.java:337)
    	at org.springframework.ws.soap.server.endpoint.AbstractSoapFaultDefinitionExceptionResolver.resolveExceptionInternal(AbstractSoapFaultDefinitionExceptionResolver.java:61)
    	at org.springframework.ws.server.endpoint.AbstractEndpointExceptionResolver.resolveException(AbstractEndpointExceptionResolver.java:106)
    	at org.springframework.ws.server.MessageDispatcher.processEndpointException(MessageDispatcher.java:330)
    	at org.springframework.ws.server.MessageDispatcher.dispatch(MessageDispatcher.java:245)
    	at org.springframework.ws.server.MessageDispatcher.receive(MessageDispatcher.java:173)
    	at org.springframework.ws.transport.support.WebServiceMessageReceiverObjectSupport.handleConnection(WebServiceMessageReceiverObjectSupport.java:88)
    	at org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter.handle(WebServiceMessageReceiverHandlerAdapter.java:59)
    	at org.springframework.ws.transport.http.MessageDispatcherServlet.doService(MessageDispatcherServlet.java:239)
    	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
    	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
    	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
    	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
    	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
    	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
    	at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:206)
    	at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
    	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    	at org.mortbay.jetty.Server.handle(Server.java:324)
    	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
    	at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
    	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
    	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
    	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
    	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
    	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
    I tried asking on Stack Overflow yesterday but haven't gotten any responses. If there is any more information I should provide, please ask. Any help I could get would be greatly appreciated it.

    EDIT: I put JAXB in the title but that was only from some tutorials I've been trying. I don't need to use it if there's something better/easier that gets the job done.
    Last edited by lancekf; Mar 19th, 2013, 08:56 AM.

  • #2
    lancekf,

    Did you get it to work? If so please post your full code. I am also trying to create a POX service using spring-ws. I am looking for tutorials about how to do.

    Comment


    • #3
      Unfortunately, no. I only needed to respond with one static message for every request so what I ended up doing was set up a Spring MVC web app that mapped all requests to one method, passing in an HttpServletResponse and then calling getWriter() to stream back exactly what I wanted. Was very simple and worked flawlessly. It doesn't really work as well if you actually need to marshal and unmarshall objects though.

      Comment


      • #4
        Alternatively, you could use the DomPoxMessageFactory instead of a SOAP message factory. This will create Plain Old XML (i.e. non-SOAP) messages.

        Comment

        Working...
        X