Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Problem using AbstractStaxEventPayloadEndpoint

  1. #1

    Question 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. #2
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    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.
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

  3. #3
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

  4. #4

    Thumbs up

    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.

  5. #5

    Question 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?

  6. #6

    Cool

    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...

  7. #7
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    Quote 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.
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

  8. #8
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    Quote 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,
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

  9. #9

    Default

    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?

  10. #10
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    Quote 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.
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •