Package org.apache.servicemix.soap.marshalers

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


                    }
                    exchange = (InOut) store.load(message.getJMSCorrelationID());
                    if (exchange == null) {
                        throw new IllegalStateException("Could not find exchange " + message.getJMSCorrelationID());
                    }
                    SoapMessage soap = endpoint.getMarshaler().toSOAP(message);
                    NormalizedMessage out = exchange.createMessage();
                    soapHelper.getJBIMarshaler().toNMS(out, soap);
                    ((InOut) exchange).setOutMessage(out);
                    channel.send(exchange);
                } catch (Exception e) {
View Full Code Here


    QName relatesToQN = new QName(WSAddressingConstants.WSA_NAMESPACE_200408, WSAddressingConstants.EL_RELATES_TO, "");

   
    // create messages and add them to the context
    Context msgContext = new Context();
    SoapMessage inMessage = new SoapMessage();
    SoapMessage outMessage = new SoapMessage();
    msgContext.setInMessage(inMessage);
    msgContext.setOutMessage(outMessage);
   
    // add wsa MessageID header to in message
    String messageId = "uuid:1234567890";
    DocumentFragment wsaMessageId = this.handler.createHeader(messageIdQN, messageId);
    inMessage.addHeader(messageIdQN, wsaMessageId);
   
    // run handler
    this.handler.onReply(msgContext);
   
    // verify relates-to
    DocumentFragment wsaRelatesTo = (DocumentFragment) outMessage.getHeaders().get(relatesToQN);
    assertNotNull("No RelatesTo header", wsaRelatesTo);
    assertEquals("Value", messageId, wsaRelatesTo.getTextContent());
  }
View Full Code Here

    QName relatesToQN = new QName(WSAddressingConstants.WSA_NAMESPACE_200408, WSAddressingConstants.EL_RELATES_TO, WSAddressingConstants.WSA_PREFIX);

   
    // create messages and add them to the context
    Context msgContext = new Context();
    SoapMessage inMessage = new SoapMessage();
    SoapMessage outMessage = new SoapMessage();
    msgContext.setInMessage(inMessage);
    msgContext.setOutMessage(outMessage);
   
    // add wsa MessageID header to in message
    String messageId = "uuid:1234567890";
    DocumentFragment wsaMessageId = this.handler.createHeader(messageIdQN, messageId);
    inMessage.addHeader(messageIdQN, wsaMessageId);
   
    // run handler
    this.handler.onReply(msgContext);
   
    // verify relates-to
    DocumentFragment wsaRelatesTo = (DocumentFragment) outMessage.getHeaders().get(relatesToQN);
    assertNotNull("No RelatesTo header", wsaRelatesTo);
    assertEquals("Value", messageId, wsaRelatesTo.getTextContent());
  }
View Full Code Here

    }

    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 (WSAddressingConstants.EL_MESSAGE_ID.equals(qname.getLocalPart())) {
                        QName name = new QName(qname.getNamespaceURI(), WSAddressingConstants.EL_MESSAGE_ID, qname.getPrefix() != null ? qname.getPrefix() : WSAddressingConstants.WSA_PREFIX);
                        DocumentFragment df = createHeader(name, idGenerator.generateSanitizedId());
                        out.addHeader(name, df);
                        name = new QName(qname.getNamespaceURI(), WSAddressingConstants.EL_RELATES_TO, qname.getPrefix() != null ? qname.getPrefix() : WSAddressingConstants.WSA_PREFIX);
                        df = createHeader(name, getHeaderText(value));
                        out.addHeader(name, df);
                    }
                }
            }
        }
    }
View Full Code Here

        exchange.setMessage(inMessage, "in");
        return exchange;
    }

    public SoapMessage onReply(Context context, NormalizedMessage outMsg) throws Exception {
        SoapMessage out = new SoapMessage();
        if (context.getInMessage() != null) {
            out.setEnvelopeName(context.getInMessage().getEnvelopeName());
        }
        jbiMarshaler.fromNMS(out, outMsg);
        context.setOutMessage(out);
        if (policies != null) {
            for (Iterator it = policies.iterator(); it.hasNext();) {
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.