Package org.codehaus.xfire

Examples of org.codehaus.xfire.MessageContext


        type.setSchemaType(new QName("urn:test", "strings"));
   
        // Test reading
        ElementReader reader = new ElementReader(getResourceAsStream("/org/codehaus/xfire/aegis/type/basic/strings.xml"));
       
        String[] strings = (String[]) type.readObject(reader, new MessageContext());
        assertEquals(3, strings.length);
        assertEquals("foo", strings[0]);
        assertEquals(null, strings[1]);
        assertEquals("", strings[2]);
        reader.getXMLStreamReader().close();
       
        // Test writing
        Element element = new Element("strings", "t", "urn:test");
        Document doc = new Document(element);
        JDOMWriter writer = new JDOMWriter(element);
        type.writeObject(strings, writer, new MessageContext());
        writer.close();
   
        addNamespace("xsi", SoapConstants.XSI_NS);
        assertValid("/t:strings/t:string[text()='" + strings[0] +"']", element);
        assertValid("/t:strings/t:string[@xsi:nil='true']", element);
View Full Code Here


        type.setSchemaType(new QName("urn:test", "ints"));

        // Test reading
        ElementReader reader = new ElementReader(getResourceAsStream("/org/codehaus/xfire/aegis/type/basic/ints1.xml"));
       
        int[] ints = (int[]) type.readObject(reader, new MessageContext());
        assertEquals(1, ints.length);
       
        reader.getXMLStreamReader().close();
       
        // Test writing
        Element element = new Element("ints", "t", "urn:test");
        Document doc = new Document(element);
        JDOMWriter writer = new JDOMWriter(element);
        type.writeObject(ints, writer, new MessageContext());
        writer.close();

        assertValid("/t:ints/t:int[text()='" + ints[0] +"']", element);
    }
View Full Code Here

        // Document to send
        StaxBuilder builder = new StaxBuilder();
        Document doc = builder.build(getResourceAsStream("/org/codehaus/xfire/transport/jms/echo.xml"));

        MessageContext mc = new MessageContext();

        OutMessage msg = new OutMessage(peer2);
        msg.setSerializer(new JDOMSerializer());
        msg.setBody(doc);
View Full Code Here

        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(bos);
        writer.writeStartDocument();
       
        SourceType st = new SourceType();
        st.writeObject(s, new ElementWriter(writer), new MessageContext());
       
        writer.writeEndDocument();
    }
View Full Code Here

        XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(bos);
       
        writer.writeStartDocument();
       
        SourceType st = new SourceType();
        st.writeObject(s, new ElementWriter(writer), new MessageContext());
       
        writer.writeEndDocument();
    }
View Full Code Here

       
        // Test reading
        ElementReader reader = new ElementReader(getResourceAsStream("/org/codehaus/xfire/aegis/type/collection/Map.xml"));
        //MessageReader creader = reader.getNextElementReader();
       
        Map m = (Map) type.readObject(reader, new MessageContext());
        assertEquals(2, m.size());
        assertEquals("value1", m.get("key1"));
        assertEquals("value2", m.get("key2"));
       
        reader.getXMLStreamReader().close();
       
        // Test writing
        Element element = new Element("map", "urn:test");
        Document doc = new Document(element);
        JDOMWriter writer = new JDOMWriter(element);
        type.writeObject(m, writer, new MessageContext());
        writer.close();

        assertValid("/t:map/t:entry[1]/t:key[text()='key1']", element);
        assertValid("/t:map/t:entry[1]/t:value[text()='value1']", element);
View Full Code Here

        registerSimpleBeanType(tm);

        BeanType bt = (BeanType) tm.getType(SimpleBean.class);

        ElementWriter lwriter = new ElementWriter(writer, "SimpleBean", "urn:Bean");
        bt.writeObject(bean, lwriter, new MessageContext());
        lwriter.close();

        writer.close();

        System.out.println(bos.toString());
        // XMLInputFactory factory = XMLInputFactory.newInstance();
        // XMLStreamReader reader = factory.createXMLStreamReader( new
        // StringReader(bos.toString()) );
        XMLStreamReader reader = STAXUtils.createXMLStreamReader(new StringReader(bos.toString()));
        while (reader.getEventType() != XMLStreamReader.START_ELEMENT)
            reader.next();

        SimpleBean readBean = (SimpleBean) bt.readObject(new ElementReader(reader), new MessageContext());
        assertNotNull(readBean);
        assertEquals("bleh", readBean.getBleh());
        assertEquals("howdy", readBean.getHowdy());

        Element root = new Element("root");
View Full Code Here

        ArrayType at = (ArrayType) tm.getType(SimpleBean[].class);

        at.writeObject(beanArray,
                       new ElementWriter(writer, "SimpleBean", "urn:Bean"),
                       new MessageContext());
        writer.close();

        /*
         * TODO: figure out why this doesn't work. It works when you're actually
         * reading/writing documents. I think it has something to do with the
View Full Code Here

       
        // Document to send
        StaxBuilder builder = new StaxBuilder();
        Document doc = builder.build(getResourceAsStream("/org/codehaus/xfire/xmpp/echo.xml"));

        MessageContext context = new MessageContext();

        OutMessage msg = new OutMessage(id + "/" + peer2);
        msg.setSerializer(new SoapSerializer(new JDOMSerializer()));
        msg.setBody(doc);
View Full Code Here

       
        // Document to send
        StaxBuilder builder = new StaxBuilder();
        Document doc = builder.build(getResourceAsStream("/org/codehaus/xfire/xmpp/echo.xml"));
       
        MessageContext context = new MessageContext();

        OutMessage msg = new OutMessage(id + "/Echo");
        msg.setSerializer(new SoapSerializer(new JDOMSerializer()));
        msg.setBody(doc);
View Full Code Here

TOP

Related Classes of org.codehaus.xfire.MessageContext

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.