package org.codehaus.xfire.util;

import javax.xml.stream.XMLStreamException;

import org.codehaus.xfire.MessageContext;
import org.codehaus.xfire.exchange.InMessage;
import org.codehaus.xfire.transport.ChannelEndpoint;
import org.codehaus.yom.Document;
import org.codehaus.yom.stax.StaxBuilder;

public class YOMEndpoint
    implements ChannelEndpoint
{
    private int count = 0;
    private Document message;
    
    public void onReceive(MessageContext context, InMessage msg)
    {
        count++;
        StaxBuilder builder = new StaxBuilder();
        try
        {
            message = new Document(builder.buildElement(null, msg.getXMLStreamReader()));
        }
        catch (XMLStreamException e)
        {
            e.printStackTrace();
        }
    }

    public int getCount()
    {
        return count;
    }

    public Document getMessage()
    {
        return message;
    }
}
@@ -243,24 +243,57 @@
 m.Document;%0A
+import org.codehaus.yom.Element;%0A
 import org.c
@@ -618,31 +618,23 @@
     
-message = new Document(
+Element root = 
 buil
@@ -681,18 +681,198 @@
 eader())
-)
 ;
+%0A            if (root != null)%0A            %7B%0A                message = new Document(root);%0A            %7D%0A            else%0A            %7B%0A                message = null;%0A            %7D
 %0A       

Check for no message