Package org.apache.servicemix.soap.marshalers

Examples of org.apache.servicemix.soap.marshalers.SoapMessage


    }

    public void testUserNameToken() throws Exception {
        SoapMarshaler marshaler = new SoapMarshaler(true, true);
        SoapReader reader = marshaler.createReader();
        SoapMessage msg = reader.read(getClass().getResourceAsStream("sample-wsse-request.xml"));
        Context ctx = new Context();
        ctx.setInMessage(msg);
       
        WSSecurityHandler handler = new WSSecurityHandler();
        handler.setAuthenticationService(new JAASAuthenticationService());
View Full Code Here


        assertTrue(ctx.getInMessage().getSubject().getPrincipals().size() > 0);
    }
   
    public void testSignatureRoundtrip() throws Exception {
        SoapMarshaler marshaler = new SoapMarshaler(true, true);
        SoapMessage msg = new SoapMessage();
        Context ctx = new Context();
        ctx.setInMessage(msg);
        msg.setSource(new StringSource("<hello>world</hello>"));
        SoapWriter writer = marshaler.createWriter(ctx.getInMessage());
        W3CDOMStreamWriter domWriter = new W3CDOMStreamWriter();
        writer.writeSoapEnvelope(domWriter);
        ctx.getInMessage().setDocument(domWriter.getDocument());
       
View Full Code Here

    }
   
    public void testSignatureServer() throws Exception {
        SoapMarshaler marshaler = new SoapMarshaler(true, true);
        SoapReader reader = marshaler.createReader();
        SoapMessage msg = reader.read(getClass().getResourceAsStream("signed.xml"));
        Context ctx = new Context();
        ctx.setInMessage(msg);
       
        StandaloneCrypto crypto = new StandaloneCrypto();
        crypto.setKeyStoreUrl(new ClassPathResource("privatestore.jks"));
View Full Code Here

    }
   
    public void testBadSignatureServer() throws Exception {
        SoapMarshaler marshaler = new SoapMarshaler(true, true);
        SoapReader reader = marshaler.createReader();
        SoapMessage msg = reader.read(getClass().getResourceAsStream("signed-bad.xml"));
        Context ctx = new Context();
        ctx.setInMessage(msg);
       
        StandaloneCrypto crypto = new StandaloneCrypto();
        crypto.setKeyStoreUrl(new ClassPathResource("privatestore.jks"));
View Full Code Here

   
    protected final SourceTransformer sourceTransformer = new SourceTransformer();
    protected final IdGenerator idGenerator = new IdGenerator();
   
  public void onReceive(Context context) throws Exception {
    SoapMessage message = context.getInMessage();
      String action = null;
      String to = null;
      String nsUri = null;
      Map headers = message.getHeaders();
      if (headers != null) {
        for (Iterator it = headers.keySet().iterator(); it.hasNext();) {
          QName qname = (QName) it.next();
          Object value = headers.get(qname);
                if (isWSANamespace(qname.getNamespaceURI())) {
View Full Code Here

        }
      }
  }
   
    public void onReply(Context context) throws Exception {
        SoapMessage in = context.getInMessage();
        SoapMessage out = context.getOutMessage();
        Map headers = in.getHeaders();
        if (headers != null) {
            for (Iterator it = headers.keySet().iterator(); it.hasNext();) {
                QName qname = (QName) it.next();
                Object value = headers.get(qname);
                if (isWSANamespace(qname.getNamespaceURI())) {
                    if (EL_MESSAGE_ID.equals(qname.getLocalPart())) {
                        QName name = new QName(qname.getNamespaceURI(), EL_MESSAGE_ID, qname.getPrefix() != null ? qname.getPrefix() : WSA_PREFIX);
                        DocumentFragment df = createHeader(name, idGenerator.generateSanitizedId());
                        out.addHeader(name, df);
                        name = new QName(qname.getNamespaceURI(), EL_RELATES_TO, qname.getPrefix() != null ? qname.getPrefix() : WSA_PREFIX);
                        df = createHeader(name, getHeaderText(value));
                        out.addHeader(name, df);
                    }
                }
            }
        }
    }
View Full Code Here

    protected void doStop() throws Exception {
    }
   
    protected void fromNMS(NormalizedMessage nm, TextMessage msg) throws Exception {
        Map headers = (Map) nm.getProperty(JbiConstants.PROTOCOL_HEADERS);
        SoapMessage soap = new SoapMessage();
        soapHelper.getJBIMarshaler().fromNMS(soap, nm);
        fromNMS(soap, msg, headers);
    }
View Full Code Here

            is = new ByteArrayInputStream(bytes);
        } else {
            throw new IllegalArgumentException("JMS message should be a text or bytes message");
        }
        String contentType = message.getStringProperty(CONTENT_TYPE);
        SoapMessage soap = soapHelper.getSoapMarshaler().createReader().read(is, contentType);
        ctx.setInMessage(soap);
        ctx.setProperty(Message.class.getName(), message);
        MessageExchange exchange = soapHelper.onReceive(ctx);
        // TODO: copy protocol messages
        //inMessage.setProperty(JbiConstants.PROTOCOL_HEADERS, getHeaders(message));
View Full Code Here

            response = session.createObjectMessage(e);
        } else if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
            Fault jbiFault = exchange.getFault();
            if (jbiFault != null) {
                SoapFault fault = new SoapFault(SoapFault.RECEIVER, null, null, null, jbiFault.getContent());
                SoapMessage soapFault = soapHelper.onFault(ctx, fault);
                TextMessage txt = session.createTextMessage();
                fromNMS(soapFault, txt, (Map) jbiFault.getProperty(JbiConstants.PROTOCOL_HEADERS));
                response = txt;
            } else {
                NormalizedMessage outMsg = exchange.getMessage("out");
                if (outMsg != null) {
                    SoapMessage out = soapHelper.onReply(ctx, outMsg);
                    TextMessage txt = session.createTextMessage();
                    fromNMS(out, txt, (Map) outMsg.getProperty(JbiConstants.PROTOCOL_HEADERS));
                    response = txt;
                }
            }
View Full Code Here

                        is = new ByteArrayInputStream(bytes);
                    } else {
                        throw new IllegalArgumentException("JMS message should be a text or bytes message");
                    }
                    String contentType = message.getStringProperty(CONTENT_TYPE);
                    SoapMessage soap = soapHelper.getSoapMarshaler().createReader().read(is, contentType);
                    NormalizedMessage out = exchange.createMessage();
                    soapHelper.getJBIMarshaler().toNMS(out, soap);
                    ((InOut) exchange).setOutMessage(out);
                }
                channel.send(exchange);
View Full Code Here

TOP

Related Classes of org.apache.servicemix.soap.marshalers.SoapMessage

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.