Announcement Announcement Module
Collapse
No announcement yet.
Problem using AbstractStaxEventPayloadEndpoint Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem using AbstractStaxEventPayloadEndpoint

    Hi,

    i want to use Stax based parsing of my soap messages. So i changed the messageContextFactory to AxiomSoapMessageContextFactory and derived my endpoint class from AbstractStaxEventPayloadEndpoint.
    My implementation of invokeInternal just contains logging code at the moment. When i run a webservice call from a client i get the following exception:

    2006-06-28 15:05:51,273 WARN [org.springframework.ws.soap.SoapMessageDispatcher] - <Endpoint invocation resulted in exception - responding with SOAP Fault>
    javax.xml.stream.XMLStreamException: Can only create STaX reader for a SAXSource if Reader or InputStream exposed via getSource(); can not use other sources (like embedded SAX readers)
    at com.ctc.wstx.stax.WstxInputFactory.createSR(WstxIn putFactory.java:729)
    at com.ctc.wstx.stax.WstxInputFactory.createXMLEventR eader(WstxInputFactory.java:276)
    at org.springframework.ws.endpoint.AbstractStaxEventP ayloadEndpoint.invoke(AbstractStaxEventPayloadEndp oint.java:66)
    at org.springframework.ws.endpoint.MessageEndpointAda pter.invoke(MessageEndpointAdapter.java:32)
    at org.springframework.ws.MessageDispatcher.dispatch( MessageDispatcher.java:247)
    at org.springframework.ws.MessageDispatcher.invoke(Me ssageDispatcher.java:209)
    at org.springframework.ws.transport.http.MessageHandl erAdapter.handle(MessageHandlerAdapter.java:57)
    at org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:723)
    at org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:663)
    at org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:394)
    at org.springframework.web.servlet.FrameworkServlet.d oPost(FrameworkServlet.java:358)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:709)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:252)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:173)
    at org.springframework.web.filter.CharacterEncodingFi lter.doFilterInternal(CharacterEncodingFilter.java :75)
    at org.springframework.web.filter.OncePerRequestFilte r.doFilter(OncePerRequestFilter.java:77)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:202)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:178)
    at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:105)
    at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:107)
    at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:148)
    at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:856)
    at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.processConnection(Http11Protocol.jav a:744)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.process Socket(PoolTcpEndpoint.java:527)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThr ead.runIt(LeaderFollowerWorkerThread.java:80)
    at org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(ThreadPool.java:684)
    at java.lang.Thread.run(Unknown Source)

    thx in advance for any help!

  • #2
    Yeah, I knew about that one. It's mostly related to the STAX implementation we are using, but I can provide a workaround. I created an issue for it here.

    When I fix it, you will be able to use the AxiomSoapMessageContextFactory in combination with the AbstractStaxStreamPayloadEndpoint, and get really fast performance. (Note that you cannot use the AbstractStaxEventPayloadEndpoint, because Axiom uses XMLStreamReaders internally, and not XMLEventReaders).

    Hopefully, I will be able to fix this issue this week, but since I'm also doing a Spring training in Zurich, I don't have much time.

    Comment


    • #3
      This is now fixed in Svn

      https://svn.sourceforge.net/svnroot/...unk/spring-ws/

      Comment


      • #4
        Hi Arjen,

        i have made a similar fix for that too...using the sources included
        with the M1 Release. I tried the svn sources first but i had trouble
        to get the build process to work. The newly refactored xml modul was missing in the integration repos...
        However thx for the quick fix!
        For people needing this stuff immediatly i can provide my patched core.jar
        until the M2 release is out.

        Comment


        • #5
          XmlStreamWriter not working

          ok let's go for the next round

          I derived my endpoint class from AbstractStaxStreamPayloadEndpoint and parsing the input message via XmlStreamReader works fine.
          But when it comes to writing the response via XmlStreamWriter all i get is: <Can not create a STaX writer for a SAXResult -- not (yet) implemented.>
          Is this another issue with the woodstox StAX implementation...recognizing StaxResult as SaXResult because it is derived from such?

          Comment


          • #6
            My idea was to modify the createStreamWriter() of AbstractStaxStreamPayloadEndpoint to (similar to the workaround above):

            private void createStreamWriter() throws XMLStreamException {
            if (streamWriter == null) {
            WebServiceMessage response = messageContext.createResponse();

            final Result result = response.getPayloadResult();
            if (result instanceof StaxResult) {
            StaxResult staxResult = (StaxResult) result;
            streamWriter = staxResult.getXMLStreamWriter();
            } else {
            streamWriter = getOutputFactory().createXMLStreamWriter(
            response.getPayloadResult());
            }
            }
            }

            However the passed in Result is not an instance of StaxResult...but it should be...

            Comment


            • #7
              Originally posted by lasse_stromberg
              My idea was to modify the createStreamWriter() of AbstractStaxStreamPayloadEndpoint to (similar to the workaround above):

              private void createStreamWriter() throws XMLStreamException {
              if (streamWriter == null) {
              WebServiceMessage response = messageContext.createResponse();

              final Result result = response.getPayloadResult();
              if (result instanceof StaxResult) {
              StaxResult staxResult = (StaxResult) result;
              streamWriter = staxResult.getXMLStreamWriter();
              } else {
              streamWriter = getOutputFactory().createXMLStreamWriter(
              response.getPayloadResult());
              }
              }
              }

              However the passed in Result is not an instance of StaxResult...but it should be...
              No it shouldn't :-), because Axiom doesn't expose a XMLStreamWriter to write to, only a XMLStreamReader to read from.

              Comment


              • #8
                Originally posted by lasse_stromberg
                Hi Arjen,

                i have made a similar fix for that too...using the sources included
                with the M1 Release. I tried the svn sources first but i had trouble
                to get the build process to work. The newly refactored xml modul was missing in the integration repos...
                However thx for the quick fix!
                For people needing this stuff immediatly i can provide my patched core.jar
                until the M2 release is out.
                I will provide a snapshot build tomorrow as well, so you don't have to wait until M2.

                Hope that helps,

                Comment


                • #9
                  No it shouldn't :-), because Axiom doesn't expose a XMLStreamWriter to write to, only a XMLStreamReader to read from.
                  Arjen you are right! But how can i create an XmlStreamWriter for building the response message?

                  Comment


                  • #10
                    Originally posted by lasse_stromberg
                    Arjen you are right! But how can i create an XmlStreamWriter for building the response message?
                    You can use a XMLStreamWriter, but the result it writes to will be buffered in an byte array, and that will be placed in the payload when you call endDocument() on the writer.

                    I think that's the only way it can be solved, until Axiom exposes a XMLStreamWriter.

                    Comment


                    • #11
                      Hello Arjen,

                      i got your idea. But can you be more specific on where i have to make changes to get this working?
                      For example i'm not sure if i have to change the returned Result in AxiomSoapMessage from SaxResult to a StreamResult (using a ByteBuffer)...

                      thanks & regards!

                      Comment


                      • #12
                        You'll have to wait a couple of hours before I do the snapshot release (just working on one final issue now), and then you can use it.

                        Comment

                        Working...
                        X