Package org.apache.servicemix.soap.marshalers

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


        }
        return out;
    }

    public SoapMessage onFault(Context context, SoapFault fault) throws Exception {
        SoapMessage soapFault = new SoapMessage();
        soapFault.setFault(fault);
        if (context == null) {
            context = new Context();
        }
        if (context.getInMessage() != null) {
            soapFault.setEnvelopeName(context.getInMessage().getEnvelopeName());
        }
        context.setFaultMessage(soapFault);
        if (policies != null) {
            for (Iterator it = policies.iterator(); it.hasNext();) {
                Handler policy = (Handler) it.next();
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

        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

        }
        return out;
    }

    public SoapMessage onFault(Context context, SoapFault fault) throws Exception {
        SoapMessage soapFault = new SoapMessage();
        soapFault.setFault(fault);
        if (context == null) {
            context = new Context();
        }
        if (context.getInMessage() != null) {
            soapFault.setEnvelopeName(context.getInMessage().getEnvelopeName());
        }
        context.setFaultMessage(soapFault);
        if (policies != null) {
            for (Iterator it = policies.iterator(); it.hasNext();) {
                Handler policy = (Handler) it.next();
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

                                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

                        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

        NormalizedMessage nm = exchange.getMessage("in");
        if (nm == null) {
            throw new IllegalStateException("Exchange has no input message");
        }
        PostMethod method = new PostMethod(relUri);
        SoapMessage soapMessage = new SoapMessage();
        soapHelper.getJBIMarshaler().fromNMS(soapMessage, nm);
        Context context = soapHelper.createContext(soapMessage);
        soapHelper.onSend(context);
        SoapWriter writer = soapHelper.getSoapMarshaler().createWriter(soapMessage);
        Map headers = (Map) nm.getProperty(JbiConstants.PROTOCOL_HEADERS);
View Full Code Here

        Continuation cont = ContinuationSupport.getContinuation(request, null);
        MessageExchange exchange;
        // If the continuation is not a retry
        if (!cont.isPending()) {
            try {
                SoapMessage message = soapHelper.getSoapMarshaler().createReader().read(
                                            request.getInputStream(),
                                            request.getHeader(Constants.HEADER_CONTENT_TYPE));
                Context context = soapHelper.createContext(message);
                if (request.getUserPrincipal() != null) {
                    if (request.getUserPrincipal() instanceof JaasJettyPrincipal) {
                        Subject subject = ((JaasJettyPrincipal) request.getUserPrincipal()).getSubject();
                        context.getInMessage().setSubject(subject);
                    } else {
                        context.getInMessage().addPrincipal(request.getUserPrincipal());
                    }
                }
                request.setAttribute(Context.class.getName(), context);
                exchange = soapHelper.onReceive(context);
                NormalizedMessage inMessage = exchange.getMessage("in");
                inMessage.setProperty(JbiConstants.PROTOCOL_HEADERS, getHeaders(request));
                locks.put(exchange.getExchangeId(), cont);
                request.setAttribute(MessageExchange.class.getName(), exchange.getExchangeId());
                synchronized (cont) {
                    ((BaseLifeCycle) endpoint.getServiceUnit().getComponent().getLifeCycle()).sendConsumerExchange(exchange, endpoint);
                    if (exchanges.remove(exchange.getExchangeId()) == null) {
                        if (log.isDebugEnabled()) {
                            log.debug("Suspending continuation for exchange: " + exchange.getExchangeId());
                        }
                        // TODO: make this timeout configurable
                        boolean result = cont.suspend(1000 * 60); // 60 s
                        if (!result) {
                            throw new Exception("Error sending exchange: aborted");
                        }
                    }
                    request.removeAttribute(MessageExchange.class.getName());
                }
            } catch (SoapFault fault) {
                sendFault(fault, request, response);
                return;
            }
        } else {
            String id = (String) request.getAttribute(MessageExchange.class.getName());
            exchange = (MessageExchange) exchanges.remove(id);
            request.removeAttribute(MessageExchange.class.getName());
            boolean result = cont.suspend(0);
            // Check if this is a timeout
            if (exchange == null) {
                throw new IllegalStateException("Exchange not found");
            }
            if (!result) {
                throw new Exception("Timeout");
            }
        }
        if (exchange.getStatus() == ExchangeStatus.ERROR) {
            if (exchange.getError() != null) {
                throw new Exception(exchange.getError());
            } else {
                throw new Exception("Unknown Error");
            }
        } else if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
            try {
                if (exchange.getFault() != null) {
                    SoapFault fault = new SoapFault(
                                    (QName) exchange.getFault().getProperty(JBIMarshaler.SOAP_FAULT_CODE),
                                    (QName) exchange.getFault().getProperty(JBIMarshaler.SOAP_FAULT_SUBCODE),
                                    (String) exchange.getFault().getProperty(JBIMarshaler.SOAP_FAULT_REASON),
                                    (URI) exchange.getFault().getProperty(JBIMarshaler.SOAP_FAULT_NODE),
                                    (URI) exchange.getFault().getProperty(JBIMarshaler.SOAP_FAULT_ROLE),
                                    exchange.getFault().getContent());
                    sendFault(fault, request, response);
                } else {
                    NormalizedMessage outMsg = exchange.getMessage("out");
                    if (outMsg != null) {
                        Context context = (Context) request.getAttribute(Context.class.getName());
                        SoapMessage out = soapHelper.onReply(context, outMsg);
                        SoapWriter writer = soapHelper.getSoapMarshaler().createWriter(out);
                        response.setContentType(writer.getContentType());
                        writer.write(response.getOutputStream());
                    }
                }
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.