Package org.codehaus.xfire.util.stax

Examples of org.codehaus.xfire.util.stax.DepthXMLStreamReader


    public void doSkipTest() throws Exception
    {
        XMLStreamReader reader = STAXUtils.createXMLStreamReader(getClass().getResourceAsStream("/org/codehaus/xfire/util/nowhitespace.xml"),null,null);
        //XMLStreamReader reader = ifactory.createXMLStreamReader(getClass().getResourceAsStream("/org/codehaus/xfire/util/nowhitespace.xml"));
       
        DepthXMLStreamReader dr = new DepthXMLStreamReader(reader);
        STAXUtils.toNextElement(dr);
        assertEquals("Envelope", dr.getLocalName());
        dr.next();
        STAXUtils.toNextElement(dr);
        assertEquals("Header", dr.getLocalName());
    }
View Full Code Here


        throws XFireFault
    {
        List parameters = new ArrayList();
        OperationInfo opInfo = context.getExchange().getOperation();
       
        DepthXMLStreamReader dr = new DepthXMLStreamReader(context.getInMessage().getXMLStreamReader());
        int param = 0;
        boolean clientMode = isClientModeOn(context);
       
        while (STAXUtils.toNextElement(dr))
        {
            MessagePartInfo p;
           
            if (opInfo != null && clientMode)
            {
                p = (MessagePartInfo) opInfo.getOutputMessage().getMessageParts().get(param);
            }
            else if (opInfo != null && !clientMode)
            {
                p = (MessagePartInfo) opInfo.getInputMessage().getMessageParts().get(param);
            }
            else
            {
                // Try to intelligently find the right part if we don't know the operation yet.
                p = findMessagePart(context, operations, dr.getName(), param);
            }
           
            if (p == null)
            {
                throw new XFireFault("Parameter " + dr.getName() + " does not exist!",
                                     XFireFault.SENDER);
            }

            param++;
            parameters.add( context.getService().getBindingProvider().readParameter(p, dr, context) );
           
            if (dr.getEventType() == XMLStreamReader.END_ELEMENT) nextEvent(dr);
        }

        if (opInfo == null && !clientMode)
        {
            opInfo = findOperation(operations, parameters);
View Full Code Here

    public void readMessage(InMessage inMessage, MessageContext context)
        throws XFireFault
    {
        Service endpoint = context.getService();
       
        DepthXMLStreamReader dr = new DepthXMLStreamReader(context.getInMessage().getXMLStreamReader());

        if ( !STAXUtils.toNextElement(dr) )
            throw new XFireFault("There must be a method name element.", XFireFault.SENDER);
       
        OperationInfo op = context.getExchange().getOperation();

        if (!isClientModeOn(context) && op == null)
        {
            op = endpoint.getServiceInfo().getOperation( dr.getLocalName() );
           
            if (op == null)
            {
                throw new XFireFault("Invalid operation: " + dr.getName(), XFireFault.SENDER);
            }

            setOperation(op, context);
        }
       
View Full Code Here

            operation = (OperationInfo) service.getServiceInfo().getOperations().iterator().next();
           
            setOperation(operation, context);
        }

        DepthXMLStreamReader dr = new DepthXMLStreamReader(message.getXMLStreamReader());

        final List params = new ArrayList();
        message.setBody( params );

        MessageInfo msg;
View Full Code Here

        throws XFireFault
    {
        Service endpoint = context.getService();
       
        List parameters = new ArrayList();
        DepthXMLStreamReader dr = new DepthXMLStreamReader(context.getInMessage().getXMLStreamReader());
       
        if ( !STAXUtils.toNextElement(dr) )
            throw new XFireFault("There must be a method name element.", XFireFault.SENDER);
       
        String opName = dr.getLocalName();
        if (isClientModeOn(context))
            opName = opName.substring(0, opName.lastIndexOf("Response"));
       
        OperationInfo operation = endpoint.getServiceInfo().getOperation( opName );

        if (operation == null)
            throw new XFireFault("Could not find operation: " + opName, XFireFault.SENDER);
       
        // Move from operation element to whitespace or start element
        nextEvent(dr);
       
        setOperation(operation, context);

        if (operation == null)
        {
            throw new XFireFault("Invalid operation.", XFireFault.SENDER);
        }

        Service service = context.getService();
       
        MessageInfo msg;
        if (isClientModeOn(context))
            msg = operation.getOutputMessage();
        else
            msg = operation.getInputMessage();
       
        while(STAXUtils.toNextElement(dr))
        {
            MessagePartInfo p = (MessagePartInfo) msg.getMessageParts().get(parameters.size());

            if (p == null)
            {
                throw new XFireFault("Parameter " + dr.getName() + " does not exist!",
                                     XFireFault.SENDER);
            }
           
            QName name;
            if (p.getSchemaType().isAbstract())
            {
                name = new QName(service.getTargetNamespace(), dr.getLocalName());
            }
            else
            {
                name = dr.getName();
            }
           
            if (!p.getName().equals(name))
            {
                throw new XFireFault("Parameter " + dr.getName() + " does not exist!",
                                     XFireFault.SENDER);
            }
           
            parameters.add( endpoint.getBindingProvider().readParameter(p, dr, context) );
        }
View Full Code Here

    public void readMessage(InMessage message, MessageContext context)
        throws XFireFault
    {
        XFireFault fault = new XFireFault();
   
        DepthXMLStreamReader reader = new DepthXMLStreamReader(message.getXMLStreamReader());
   
        try
        {
            boolean end = false;
            while (!end && reader.hasNext())
            {
                int event = reader.next();
                switch (event)
                {
                    case XMLStreamReader.START_DOCUMENT:
                        String encoding = reader.getCharacterEncodingScheme();
                        message.setEncoding(encoding);
                        break;
                    case XMLStreamReader.END_DOCUMENT:
                        end = true;
                        break;
                    case XMLStreamReader.END_ELEMENT:
                        break;
                    case XMLStreamReader.START_ELEMENT:
                        if (reader.getLocalName().equals("Code"))
                        {
                            reader.next();
                            STAXUtils.toNextElement(reader);
                           
                            if (reader.getLocalName().equals("Value"))
                            {
                                fault.setFaultCode(NamespaceHelper.readQName(reader));
                            }
                        }
                        else if (reader.getLocalName().equals("SubCode"))
                        {
                            reader.next();
                            STAXUtils.toNextElement(reader);
                           
                            if (reader.getLocalName().equals("Value"))
                            {
                                fault.setSubCode(NamespaceHelper.readQName(reader));
                            }
                           
                        }
                        else if (reader.getLocalName().equals("Reason"))
                        {
                            reader.next();
                            STAXUtils.toNextElement(reader);
                           
                            if (reader.getLocalName().equals("Text"))
                            {
                                fault.setMessage(reader.getElementText());
                            }
                        }
                        else if (reader.getLocalName().equals("Actor"))
                        {
                            fault.setRole(reader.getElementText());
                        }
                        else if (reader.getLocalName().equals("Detail"))
                        {
                            StaxBuilder builder = new StaxBuilder();
                            fault.setDetail(builder.build(new FragmentStreamReader(reader)).getRootElement());
                        }
                        break;
View Full Code Here

        depth = root.getDepth();
    }

    public ElementReader(XMLStreamReader reader)
    {
        this(new DepthXMLStreamReader(reader));
    }
View Full Code Here

        // XMLStreamReader xmlReader = factory.createXMLStreamReader(is);
        XMLStreamReader xmlReader = STAXUtils.createXMLStreamReader(is, null, null);

        xmlReader.nextTag();

        this.root = new DepthXMLStreamReader(xmlReader);
        this.localName = root.getLocalName();
        this.name = root.getName();
        this.namespace = root.getNamespaceURI();

        extractXsiType();
View Full Code Here

    public void readMessage(InMessage message, MessageContext context)
        throws XFireFault
    {
        Service endpoint = context.getService();
       
        DepthXMLStreamReader dr = new DepthXMLStreamReader(context.getInMessage().getXMLStreamReader());

        if ( !STAXUtils.toNextElement(dr) )
            throw new XFireFault("There must be a method name element.", XFireFault.SENDER);
       
        OperationInfo op = context.getExchange().getOperation();

        if (!isClientModeOn(context) && op == null)
        {
            op = endpoint.getServiceInfo().getOperation( dr.getLocalName() );

            if (op != null)
            {
                setOperation(op, context);
   
View Full Code Here

TOP

Related Classes of org.codehaus.xfire.util.stax.DepthXMLStreamReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.