Package org.codehaus.xfire

Examples of org.codehaus.xfire.MessageContext


    {
        Document doc = readDocument("wsse-request-clean.xml");
       
        WSS4JOutHandler handler = new WSS4JOutHandler();
       
        MessageContext ctx = new MessageContext();
   
        OutMessage msg = new OutMessage("");
        msg.setProperty(DOMOutHandler.DOM_MESSAGE, doc);
   
        ctx.setCurrentMessage(msg);
        ctx.setProperty(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE);
        ctx.setProperty(WSHandlerConstants.SIG_PROP_FILE, "META-INF/xfire/outsecurity.properties");
        ctx.setProperty(WSHandlerConstants.USER, "myAlias");
        ctx.setProperty("password", "myAliasPassword");
        ctx.setProperty(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PASSWORD_TEXT);
       
        handler.invoke(ctx);
        printNode(doc);
        assertValid(doc, "//wsse:Security");
        assertValid(doc, "//wsse:Security/ds:Signature");
      
        byte[] docbytes = getMessageBytes(doc);
        XMLStreamReader reader = STAXUtils.createXMLStreamReader(new ByteArrayInputStream(docbytes), null, null);
 
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

        dbf.setValidating(false);
        dbf.setIgnoringComments(false);
        dbf.setIgnoringElementContentWhitespace(true);
        dbf.setNamespaceAware(true);
       
        DocumentBuilder db = dbf.newDocumentBuilder();
        db.setEntityResolver(new NullResolver());
        doc = STAXUtils.read(db, reader, false);
       
        WSS4JInHandler inHandler = new WSS4JInHandler();

        InMessage inmsg = new InMessage();
        inmsg.setProperty(DOMInHandler.DOM_MESSAGE, doc);

        ctx.setCurrentMessage(inmsg);
        inHandler.setProperty(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE);
        inHandler.setProperty(WSHandlerConstants.SIG_PROP_FILE, "META-INF/xfire/insecurity.properties");

        inHandler.invoke(ctx);
    }
View Full Code Here


    {
        Document doc = readDocument("wsse-request-clean.xml");
   
        WSS4JOutHandler handler = new WSS4JOutHandler();
   
        MessageContext ctx = new MessageContext();
   
        OutMessage msg = new OutMessage("");
        msg.setProperty(DOMOutHandler.DOM_MESSAGE, doc);
   
        ctx.setCurrentMessage(msg);
        ctx.setProperty(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
        ctx.setProperty(WSHandlerConstants.SIG_PROP_FILE, "META-INF/xfire/outsecurity.properties");
        ctx.setProperty(WSHandlerConstants.USER, "username");
        ctx.setProperty("password", "myAliasPassword");
        handler.invoke(ctx);
       
        assertValid(doc, "//wsse:Security");
        assertValid(doc, "//wsse:Security/wsse:UsernameToken");
        assertValid(doc, "//wsse:Security/wsse:UsernameToken/wsse:Username[text()='username']");
View Full Code Here

    {
        Document doc = readDocument("wsse-request-clean.xml");
   
        WSS4JOutHandler handler = new WSS4JOutHandler();
   
        MessageContext ctx = new MessageContext();
   
        OutMessage msg = new OutMessage("");
        msg.setProperty(DOMOutHandler.DOM_MESSAGE, doc);
   
        ctx.setCurrentMessage(msg);
        ctx.setProperty(WSHandlerConstants.ACTION, WSHandlerConstants.ENCRYPT);
        ctx.setProperty(WSHandlerConstants.SIG_PROP_FILE, "META-INF/xfire/outsecurity.properties");
        ctx.setProperty(WSHandlerConstants.ENC_PROP_FILE, "META-INF/xfire/outsecurity.properties");
        ctx.setProperty(WSHandlerConstants.USER, "myAlias");
        ctx.setProperty("password", "myAliasPassword");
        ctx.setProperty(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PASSWORD_TEXT);
       
        handler.invoke(ctx);
       
        assertValid(doc, "//wsse:Security");
        assertValid(doc, "//s:Body/xenc:EncryptedData");
View Full Code Here

    {
        Document doc = readDocument("wsse-request-clean.xml");
   
        WSS4JOutHandler handler = new WSS4JOutHandler();
   
        MessageContext ctx = new MessageContext();
   
        OutMessage msg = new OutMessage("");
        msg.setProperty(DOMOutHandler.DOM_MESSAGE, doc);
   
        ctx.setCurrentMessage(msg);
        ctx.setProperty(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE);
        ctx.setProperty(WSHandlerConstants.SIG_PROP_FILE, "META-INF/xfire/outsecurity.properties");
        ctx.setProperty(WSHandlerConstants.USER, "myAlias");
        ctx.setProperty("password", "myAliasPassword");
        ctx.setProperty(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PASSWORD_TEXT);
       
        handler.invoke(ctx);
       
        assertValid(doc, "//wsse:Security");
        assertValid(doc, "//wsse:Security/ds:Signature");
View Full Code Here

    {
        Document doc = readDocument("wsse-request-clean.xml");
   
        WSS4JOutHandler handler = new WSS4JOutHandler();
   
        MessageContext ctx = new MessageContext();
   
        OutMessage msg = new OutMessage("");
        msg.setProperty(DOMOutHandler.DOM_MESSAGE, doc);
   
        ctx.setCurrentMessage(msg);
        handler.setProperty(WSHandlerConstants.ACTION, WSHandlerConstants.TIMESTAMP);
        handler.setProperty(WSHandlerConstants.SIG_PROP_FILE, "META-INF/xfire/outsecurity.properties");
        ctx.setProperty(WSHandlerConstants.USER, "myAlias");
        ctx.setProperty("password", "myAliasPassword");
        handler.setProperty(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PASSWORD_TEXT);
       
        handler.invoke(ctx);
       
        assertValid(doc, "//wsse:Security");
View Full Code Here

        mapping.register(dtoType);
       
        // Test reading
        ElementReader reader = new ElementReader(getResourceAsStream("/org/codehaus/xfire/aegis/type/basic/dates.xml"));
       
        Object obj = dtoType.readObject(reader, new MessageContext());
        DateDTO dto = (DateDTO) obj;
        assertNotNull(dto.getDate0());
        assertNotNull(dto.getDateTime0());
        assertNotNull(dto.getDateTime1());
        assertNotNull(dto.getDateTime2());
        assertNotNull(dto.getDateTime3());
        assertNotNull(dto.getDateTime4());
       
        assertTrue ( dto.getDateTime3().before( dto.getDateTime4() ) );
       
        assertNotNull(dto.getDateTime5());
        assertNotNull(dto.getDateTime6());
       
        assertTrue ( dto.getDateTime5().before( dto.getDateTime6() ) );
       
        assertNotNull(dto.getTime0());
        assertNotNull(dto.getTime1());
       
        Element element = new Element("dates", ns);
        new Document(element);
        JDOMWriter writer = new JDOMWriter(element);
        MessageContext mc = new MessageContext();
        mc.setService(new Service(new ServiceInfo(
            new QName("larry","curly","moe"),DateTypeTest.class)));
        dtoType.writeObject(dto, writer, new MessageContext());
        writer.close();
       
        addNamespace("d", ns);
        assertValid("/d:dates/d:date0", element);
        assertValid("/d:dates/d:dateTime0", element);
View Full Code Here

        XFire xfire = endpoint.getXFire();
        Service service = endpoint.getXFireService();
        Transport t = xfire.getTransportManager().getTransport(JbiTransport.JBI_BINDING);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        Channel c = t.createChannel();
        MessageContext ctx = new MessageContext();
        ctx.setXFire(xfire);
        ctx.setService(service);
        ctx.setProperty(Channel.BACKCHANNEL_URI, out);
        ctx.setExchange(new org.codehaus.xfire.exchange.MessageExchange(ctx));
        InMessage msg = new InMessage();
        ctx.getExchange().setInMessage(msg);
        if (exchange.getOperation() != null) {
            OperationInfo op = service.getServiceInfo().getOperation(exchange.getOperation().getLocalPart());
            if (op != null) {
                ctx.getExchange().setOperation(op);
            }
        }
        ctx.setCurrentMessage(msg);
        NormalizedMessage in = exchange.getMessage("in");
        msg.setXMLStreamReader(getXMLStreamReader(in.getContent()));
        if (in.getAttachmentNames() != null && in.getAttachmentNames().size() > 0) {
            JavaMailAttachments attachments = new JavaMailAttachments();
            for (Iterator it = in.getAttachmentNames().iterator(); it.hasNext();) {
                String name = (String) it.next();
                DataHandler dh = in.getAttachment(name);
                attachments.addPart(new SimpleAttachment(name, dh));
            }
            msg.setAttachments(attachments);
        }
        EndpointDeliveryChannel.setEndpoint(endpoint);
        JBIContext.setMessageExchange(exchange);
        if (isInAndOut(exchange)) {
            // TODO ?
        }
        try {
            c.receive(ctx, msg);
        } finally {
            JBIContext.setMessageExchange(null);
            EndpointDeliveryChannel.setEndpoint(null);
        }
        c.close();
       
        // Set response or DONE status
        if (isInAndOut(exchange)) {
            if (ctx.getExchange().hasFaultMessage() && ctx.getExchange().getFaultMessage().getBody() != null) {
                String charSet = ctx.getExchange().getFaultMessage().getEncoding();
                Fault fault = exchange.getFault();
                if (fault == null) {
                    fault = exchange.createFault();
                    exchange.setFault(fault);
                }
                fault.setContent(new StringSource(out.toString(charSet)));
                XFireFault xFault = (XFireFault) ctx.getExchange().getFaultMessage().getBody();
                fault.setProperty(SOAP_FAULT_CODE, xFault.getFaultCode());
                fault.setProperty(SOAP_FAULT_REASON, xFault.getReason());
                fault.setProperty(SOAP_FAULT_ROLE, xFault.getRole());
                fault.setProperty(SOAP_FAULT_SUBCODE, xFault.getSubCode());
            } else {
                String charSet = ctx.getOutMessage().getEncoding();
                NormalizedMessage outMsg = exchange.getMessage("out");
                if (outMsg == null) {
                    outMsg = exchange.createMessage();
                    exchange.setMessage(outMsg, "out");
                }
                Attachments attachments = ctx.getCurrentMessage().getAttachments();
                if (attachments != null) {
                    for (Iterator it = attachments.getParts(); it.hasNext();) {
                        Attachment att = (Attachment) it.next();
                        outMsg.addAttachment(att.getId(), att.getDataHandler());
                    }
View Full Code Here

            }
       
            Transport t = xfire.getTransportManager().getTransport(JbiTransport.JBI_BINDING);
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            Channel c = t.createChannel();
            MessageContext ctx = new MessageContext();
            ctx.setXFire(xfire);
            ctx.setService(service);
            ctx.setProperty(Channel.BACKCHANNEL_URI, out);
            InMessage msg = new InMessage();
            XMLStreamReader xmlStreamReader = null;
            try {
                xmlStreamReader = XMLInputFactory.newInstance().createXMLStreamReader(in.getContent());
            } catch (Exception e) {
View Full Code Here

                fail(messageExchange, new JBIException("Could not get source as XMLStreamReader."));
                return;
            }
           
            InMessage in = new InMessage(reader, "");
            MessageContext context = new MessageContext();
            context.setXFire(xfire);
            context.setService(xfire.getServiceRegistry().getService(getService().getLocalPart()));

            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
            context.setProperty(Channel.BACKCHANNEL_URI, buffer);
           
            Transport transport =
                xfire.getTransportManager().getTransport(LocalTransport.BINDING_ID);
            Channel channel = transport.createChannel();
            channel.receive(context, in);

            NormalizedMessage outMessage = messageExchange.createMessage();

            marshaler.setContent(outMessage, buffer.toString());
            marshaler.toNMS(outMessage, context.getOutMessage());

            answer(messageExchange, outMessage);
        } catch (Exception e) {
            fail(messageExchange, e);
        }
View Full Code Here

            throws MessagingException {
        try {
            XMLStreamReader reader = marshaller.createStreamReader(nm);

            InMessage in = new InMessage(reader, "");
            MessageContext context = new MessageContext();
            context.setXFire(xfire);
            context.setService(xfire.getServiceRegistry().getService(getService().getLocalPart()));

            Transport transport =
                xfire.getTransportManager().getTransport(LocalTransport.BINDING_ID);
            Channel channel = transport.createChannel();
            channel.receive(context, in);
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.