Package org.apache.axis2.jaxws.message.factory

Examples of org.apache.axis2.jaxws.message.factory.SourceBlockFactory


     * outbound flow
     * @throws Exception
     */
    public void testDOMSourceOutflow() throws Exception {
        // Get the BlockFactory
        SourceBlockFactory f = (SourceBlockFactory)
            FactoryRegistry.getFactory(SourceBlockFactory.class);
       
        // Turn the content into a stream
        ByteArrayInputStream bais = new ByteArrayInputStream(sampleText.getBytes());
       
        // Create a DOM tree from the sample text
        DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
        domFactory.setNamespaceAware(true);
        DocumentBuilder domBuilder = domFactory.newDocumentBuilder();
        Document domTree = domBuilder.parse(bais);
        Node node = domTree.getDocumentElement();
        TestLogger.logger.debug(node.toString());
       
        // Create a DOMSource object from the DOM tree
        DOMSource ds = new DOMSource(node);
        node = ds.getNode();
       
        // Create a Block using the sample string as the content.  This simulates
        // what occurs on the outbound JAX-WS dispatch<Source> client
        Block block = f.createFrom(ds, null, null);
       
        // We didn't pass in a qname, so the following should return false
        assertTrue(!block.isQNameAvailable());
       
        // Assuming no handlers are installed, the next thing that will happen
View Full Code Here


     * outbound flow
     * @throws Exception
     */
    public void testSAXSourceOutflow() throws Exception {
        // Get the BlockFactory
        SourceBlockFactory f = (SourceBlockFactory)
            FactoryRegistry.getFactory(SourceBlockFactory.class);
       
        // Create a SAXSource from the sample text
        byte[] bytes = sampleText.getBytes();
        ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
        InputSource input = new InputSource(stream);
        SAXSource ss = new SAXSource(input);
       
        // Create a Block using the sample string as the content.  This simulates
        // what occurs on the outbound JAX-WS dispatch<Source> client
        Block block = f.createFrom(ss, null, null);
       
        // We didn't pass in a qname, so the following should return false
        assertTrue(!block.isQNameAvailable());
       
        // Assuming no handlers are installed, the next thing that will happen
View Full Code Here

    MessageFactory mf = (MessageFactory) FactoryRegistry
        .getFactory(MessageFactory.class);
    Message m = mf.create(Protocol.soap11);

    // Get the BlockFactory
    SourceBlockFactory f = (SourceBlockFactory) FactoryRegistry
        .getFactory(SourceBlockFactory.class);

    Block block = f.createFrom(new StreamSource(new StringReader(sampleText)), null, null);
   
    // Add the block to the message as normal body content.
    m.setBodyBlock(block);

    MessageContext messageContext = new MessageContext();
View Full Code Here

     * normal Dispatch<Source> flow
     * @throws Exception
     */
    public void testStreamSourceOutflow() throws Exception {
        // Get the BlockFactory
        SourceBlockFactory f = (SourceBlockFactory)
        FactoryRegistry.getFactory(SourceBlockFactory.class);

        StreamSource ss = new StreamSource(new StringReader(sampleText));

        // Create a Block using the sample string as the content.  This simulates
        // what occurs on the outbound JAX-WS dispatch<Source> client
        Block block = f.createFrom(ss, null, null);

        // We didn't pass in a qname, so the following should return false
        assertTrue(!block.isQNameAvailable());

        // Assuming no handlers are installed, the next thing that will happen
View Full Code Here

     * simulate a different Dispatch<Source> flow
     * @throws Exception
     */
    public void testStreamSourceOutflow2() throws Exception {
        // Get the BlockFactory
        SourceBlockFactory f = (SourceBlockFactory)
        FactoryRegistry.getFactory(SourceBlockFactory.class);

        StreamSource ss = new StreamSource(new StringReader(sampleText));

        // Create a Block using the sample string as the content.  This simulates
        // what occurs on the outbound JAX-WS dispatch<Source> client
        Block block = f.createFrom(ss, null, null);

        // We didn't pass in a qname, so the following should return false
        assertTrue(!block.isQNameAvailable());

        // Assume that we need to find the QName (perhaps to identify the operation and
View Full Code Here

     * simulate a different Source parameter flow
     * @throws Exception
     */
    public void testStreamSourceOutflow3() throws Exception {
        // Get the BlockFactory
        SourceBlockFactory f = (SourceBlockFactory)
        FactoryRegistry.getFactory(SourceBlockFactory.class);

        StreamSource ss = new StreamSource(new StringReader(sampleText));

        // Create a Block using the sample string as the content.  This simulates
        // what occurs on the outbound JAX-WS String parameter on the client.
        // In this case, we know the QName prior to creating the Block...so let's pass it in.
        Block block = f.createFrom(ss, null, sampleQName);

        // We passed in a qname, so it should be immediately available
        assertTrue(block.isQNameAvailable());

        // Make sure the QName is correct.
View Full Code Here

     * normal Dispatch<Source> input flow
     * @throws Exception
     */
    public void testStreamSourceInflow() throws Exception {
        // Get the BlockFactory
        SourceBlockFactory f = (SourceBlockFactory)
        FactoryRegistry.getFactory(SourceBlockFactory.class);

        // On inbound, there will already be a XMLStreamReader (probably from OM)
        // which represents the message.  We will simulate this with inflow.
        StringReader sr = new StringReader(sampleText);
        XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr);

        // Create a Block from the inflow. 
        Block block = f.createFrom(inflow, null, null);

        // Assuming no handlers are installed, the next thing that will happen
        // is the proxy code will ask for the business object (String).
        Object bo = block.getBusinessObject(true);
        assertTrue(bo instanceof Source);
View Full Code Here

     * @throws Exception
     */
    public void testStreamSourceInflow2() throws Exception {

        // Get the BlockFactory
        SourceBlockFactory f = (SourceBlockFactory)
        FactoryRegistry.getFactory(SourceBlockFactory.class);

        // On inbound, there will already be a XMLStreamReader (probably from OM)
        // which represents the message.  We will simulate this with inflow.
        StringReader sr = new StringReader(sampleText);
        XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr);

        // Create a Block from the inflow. 
        Block block = f.createFrom(inflow, null, null);

        // Let's assume we need to get the QName to find the operation name.
        // This will cause an underlying parse
        QName qName = block.getQName();
        assertTrue(sampleQName.equals(qName));
View Full Code Here

     * @throws Exception
     */
    public void testStreamSourceInflow3() throws Exception {

        // Get the BlockFactory
        SourceBlockFactory f = (SourceBlockFactory)
        FactoryRegistry.getFactory(SourceBlockFactory.class);

        // On inbound, there will already be a XMLStreamReader (probably from OM)
        // which represents the message.  We will simulate this with inflow.
        StringReader sr = new StringReader(sampleText);
        XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr);

        // Create a Block from the inflow.  Assume that we know the QName already
        Block block = f.createFrom(inflow, null, sampleQName);

        // We passed in a qname, so the following should return false
        assertTrue(block.isQNameAvailable());

        // Let's assume we need to get the QName to find the operation name.
View Full Code Here

        //Sample text for JAXBSource
        String echoSample = "<echoString xmlns=\"http://test\"><input>Hello World</input></echoString>";

        // Get the BlockFactory
        SourceBlockFactory f = (SourceBlockFactory)
        FactoryRegistry.getFactory(SourceBlockFactory.class);
        //Create a JAXBSource

        JAXBContext context = JAXBContext.newInstance("test");

        Unmarshaller u = context.createUnmarshaller();
        ByteArrayInputStream inputStream = new ByteArrayInputStream(echoSample.getBytes());
        EchoString jaxb = (EchoString)u.unmarshal(inputStream);
        JAXBSource src = new JAXBSource(context.createMarshaller(), jaxb);

        // Create a Block using the sample string as the content.  This simulates
        // what occurs on the outbound JAX-WS dispatch<Source> client
        Block block = f.createFrom(src, null, null);

        // We didn't pass in a qname, so the following should return false
        assertTrue(!block.isQNameAvailable());

        // Assuming no handlers are installed, the next thing that will happen
View Full Code Here

TOP

Related Classes of org.apache.axis2.jaxws.message.factory.SourceBlockFactory

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.