Package org.codehaus.xfire

Examples of org.codehaus.xfire.MessageContext


        FileOutputStream fos = new FileOutputStream(file);
        ElementWriter writer = new ElementWriter(fos, "root", "urn:test");
        MessageWriter b64writer = writer.getElementWriter("base64", "urn:test");
        type.writeObject(data,
                         b64writer,
                         new MessageContext());
        b64writer.close();

        b64writer = writer.getElementWriter("base64", "urn:test");
        type.writeObject(data,
                         b64writer,
                         new MessageContext());
        b64writer.close();
       
        writer.close();
        writer.flush();
        fos.close();
       
        FileInputStream fis = new FileInputStream(file);
        XMLStreamReader reader = STAXUtils.createXMLStreamReader(fis, null,null);
        reader.next();
        reader.next();
        assertEquals("base64", reader.getLocalName());
       
        byte[] data2 = (byte[]) type.readObject(new ElementReader(reader), new MessageContext());
        assertEquals(data.length, data2.length);
       
        assertEquals("base64", reader.getLocalName());
        assertEquals(XMLStreamReader.START_ELEMENT, reader.getEventType());
        data2 = (byte[]) type.readObject(new ElementReader(reader), new MessageContext());
        assertEquals(data.length, data2.length);
       
        assertEquals(XMLStreamReader.END_ELEMENT, reader.getEventType());
       
        fis.close();
View Full Code Here


        type.setSchemaType(new QName("urn:Bean", "bean"));

        // Test reading
        ElementReader reader = new ElementReader(getResourceAsStream("/org/codehaus/xfire/aegis/type/basic/bean1.xml"));
       
        SimpleBean bean = (SimpleBean) type.readObject(reader, new MessageContext());
        assertEquals("bleh", bean.getBleh());
        assertEquals("howdy", bean.getHowdy());
       
        reader.getXMLStreamReader().close();
       
        // Test reading with extra elements
        reader = new ElementReader(getResourceAsStream("/org/codehaus/xfire/aegis/type/basic/bean2.xml"));       
        bean = (SimpleBean) type.readObject(reader, new MessageContext());
        assertEquals("bleh", bean.getBleh());
        assertEquals("howdy", bean.getHowdy());
        reader.getXMLStreamReader().close();

        // test <bleh/> element
        reader = new ElementReader(getResourceAsStream("/org/codehaus/xfire/aegis/type/basic/bean7.xml"));       
        bean = (SimpleBean) type.readObject(reader, new MessageContext());
        assertEquals("", bean.getBleh());
        assertEquals("howdy", bean.getHowdy());
        reader.getXMLStreamReader().close();
       
        bean.setBleh("bleh");
       
        // Test writing
        Element element = new Element("root", "b", "urn:Bean");
        Document doc = new Document(element);
        type.writeObject(bean, new JDOMWriter(element), new MessageContext());

        assertValid("/b:root/b:bleh[text()='bleh']", element);
        assertValid("/b:root/b:howdy[text()='howdy']", element);       
    }
View Full Code Here

        type.setSchemaType(new QName("urn:Bean", "bean"));

        // Test reading
        ElementReader reader = new ElementReader(getResourceAsStream("/org/codehaus/xfire/aegis/type/basic/bean9.xml"));
       
        MessageContext ctx = new MessageContext();
        Service s = new Service();
        s.setProperty(AegisBindingProvider.READ_XSI_TYPE_KEY, "false");
        ctx.setService(s);
       
        SimpleBean bean = (SimpleBean) type.readObject(reader, ctx);
        assertEquals("bleh", bean.getBleh());
        assertEquals("howdy", bean.getHowdy());
       
        reader.getXMLStreamReader().close();
       
        // Test writing
        Element element = new Element("root", "b", "urn:Bean");
        Document doc = new Document(element);
        type.writeObject(bean, new JDOMWriter(element), new MessageContext());

        assertValid("/b:root/b:bleh[text()='bleh']", element);
        assertValid("/b:root/b:howdy[text()='howdy']", element);       
    }
View Full Code Here

        type.setTypeMapping(mapping);
        type.setSchemaType(new QName("urn:Bean", "bean"));
   
        ElementReader reader = new ElementReader(getResourceAsStream("/org/codehaus/xfire/aegis/type/basic/bean3.xml"));
       
        SimpleBean bean = (SimpleBean) type.readObject(reader, new MessageContext());
        assertEquals("howdy", bean.getHowdy());
        assertNull(bean.getBleh());
       
        reader.getXMLStreamReader().close();
       
        // Test writing
        Element element = new Element("root", "b", "urn:Bean");
        Document doc = new Document(element);
        type.writeObject(bean, new JDOMWriter(element), new MessageContext());

        assertInvalid("/b:root/b:bleh", element);
        assertValid("/b:root/b:howdycustom[text()='howdy']", element);
    }
View Full Code Here

        type.setTypeMapping(mapping);
        type.setSchemaType(new QName("urn:Bean", "bean"));
   
        ElementReader reader = new ElementReader(getResourceAsStream("/org/codehaus/xfire/aegis/type/basic/bean4.xml"));
       
        SimpleBean bean = (SimpleBean) type.readObject(reader, new MessageContext());
        assertEquals("bleh", bean.getBleh());
        assertEquals("howdy", bean.getHowdy());

        reader.getXMLStreamReader().close();
       
        // Test writing
        Element element = new Element("root", "b", "urn:Bean");
        Document doc = new Document(element);
        type.writeObject(bean, new JDOMWriter(element), new MessageContext());

        assertValid("/b:root[@b:bleh='bleh']", element);
        assertValid("/b:root[@b:howdy='howdy']", element);
       
        Element types = new Element("types", "xsd", SoapConstants.XSD);
View Full Code Here

        type.setTypeMapping(mapping);
        type.setSchemaType(new QName("urn:Bean", "bean"));
   
        ElementReader reader = new ElementReader(getResourceAsStream("/org/codehaus/xfire/aegis/type/basic/bean8.xml"));
       
        SimpleBean bean = (SimpleBean) type.readObject(reader, new MessageContext());
        assertEquals("bleh", bean.getBleh());
        assertEquals("howdy", bean.getHowdy());
   
        reader.getXMLStreamReader().close();
       
        // Test writing
   
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ElementWriter writer = new ElementWriter(bos, "root", "urn:Bean");
        type.writeObject(bean, writer, new MessageContext());
        writer.close();
        writer.flush();
       
        bos.close();
        System.out.println(bos.toString());
View Full Code Here

        SimpleBean bean = new SimpleBean();
       
        // Test writing
        Element element = new Element("root", "b", "urn:Bean");
        Document doc = new Document(element);
        type.writeObject(bean, new JDOMWriter(element), new MessageContext());
   
        assertInvalid("/b:root[@b:howdy]", element);
        assertValid("/b:root/b:bleh[@xsi:nil='true']", element);
       
        Element types = new Element("types", "xsd", SoapConstants.XSD);
View Full Code Here

        DateBean bean = new DateBean();
       
        // Test writing
        Element element = new Element("root", "b", "urn:Bean");
        Document doc = new Document(element);
        type.writeObject(bean, new JDOMWriter(element), new MessageContext());

        // Make sure the date doesn't have an element. Its non nillable so it just
        // shouldn't be there.
        assertInvalid("/b:root/b:date", element);
        assertValid("/b:root", element);
View Full Code Here

        ExtendedBean bean = new ExtendedBean();
        bean.setHowdy("howdy");
       
        Element element = new Element("root", "b", "urn:Bean");
        new Document(element);
        type.writeObject(bean, new JDOMWriter(element), new MessageContext());

        assertValid("/b:root/b:howdy[text()='howdy']", element);      
    }
View Full Code Here

        ByteBean bean = new ByteBean();
       
        // Test writing
        Element element = new Element("root", "b", "urn:Bean");
        Document doc = new Document(element);
        type.writeObject(bean, new JDOMWriter(element), new MessageContext());
   
        // Make sure the date doesn't have an element. Its non nillable so it just
        // shouldn't be there.
       
        addNamespace("xsi", SoapConstants.XSI_NS);
        assertValid("/b:root/b:data[@xsi:nil='true']", element);

        bean = (ByteBean) type.readObject(new JDOMReader(element), new MessageContext());
        assertNotNull(bean);
        assertNull(bean.getData());
    }
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.