コード例 #1
0
  protected void addMessageFromBinding(
      ExtensibilityElement ext, BindingOperationInfo bop, boolean isInput) {
    SoapHeader header = SOAPBindingUtil.getSoapHeader(ext);

    ServiceInfo serviceInfo = bop.getBinding().getService();

    if (header != null && serviceInfo.getMessage(header.getMessage()) == null) {
      Definition def = (Definition) serviceInfo.getProperty(WSDLServiceBuilder.WSDL_DEFINITION);
      SchemaCollection schemas = serviceInfo.getXmlSchemaCollection();

      if (def != null && schemas != null) {
        QName qn = header.getMessage();

        javax.wsdl.Message msg = findMessage(qn, def);
        if (msg != null) {
          addOutOfBandParts(bop, msg, schemas, isInput, header.getPart());
          serviceInfo.refresh();
        } else {
          throw new RuntimeException(
              "Problem with WSDL: soap:header element"
                  + " for operation "
                  + bop.getName()
                  + " is referring to an undefined wsdl:message element: "
                  + qn);
        }
      }
    }
  }
コード例 #2
0
 @Override
 public void handleMessage(SoapMessage message) throws Fault {
   final Header callHeader = message.getHeader(RequestCallbackFeature.CALL_ID_HEADER_NAME);
   if (callHeader == null) {
     return;
   }
   handleAddressing(message);
   final Header callbackHeader = message.getHeader(RequestCallbackFeature.CALLBACK_ID_HEADER_NAME);
   if (callbackHeader == null) {
     return;
   }
   final BindingOperationInfo boi = message.getExchange().getBindingOperationInfo();
   if (boi == null) {
     return;
   }
   final String action = SoapActionInInterceptor.getSoapAction(message);
   if (StringUtils.isEmpty(action)) {
     return;
   }
   final SoapOperationInfo soi = boi.getExtensor(SoapOperationInfo.class);
   if (soi == null) {
     return;
   }
   if (StringUtils.isEmpty(soi.getAction())) {
     soi.setAction(action);
   }
 }
コード例 #3
0
  protected String addOperationNode(
      NSStack nsStack,
      Message message,
      XMLStreamWriter xmlWriter,
      boolean output,
      BindingOperationInfo boi)
      throws XMLStreamException {
    String responseSuffix = output ? "Response" : "";
    String ns = boi.getName().getNamespaceURI();
    SoapBody body = null;
    if (output) {
      body = boi.getOutput().getExtensor(SoapBody.class);
    } else {
      body = boi.getInput().getExtensor(SoapBody.class);
    }
    if (body != null && !StringUtils.isEmpty(body.getNamespaceURI())) {
      ns = body.getNamespaceURI();
    }

    nsStack.add(ns);
    String prefix = nsStack.getPrefix(ns);
    StaxUtils.writeStartElement(
        xmlWriter, prefix, boi.getName().getLocalPart() + responseSuffix, ns);
    return ns;
  }
コード例 #4
0
  public void handleMessage(Message message) throws Fault {
    if (bus == null) {
      bus = message.getExchange().getBus();
      if (bus == null) {
        bus = BusFactory.getDefaultBus(false);
      }
      if (bus == null) {
        throw new Fault(new org.apache.cxf.common.i18n.Message("BUS_NOT_FOUND", BUNDLE));
      }
    }

    ServerRegistry registry = bus.getExtension(ServerRegistry.class);

    if (registry == null) {
      throw new Fault(new org.apache.cxf.common.i18n.Message("SERVER_REGISTRY_NOT_FOUND", BUNDLE));
    }

    Exchange exchange = message.getExchange();
    Endpoint senderEndpoint = exchange.getEndpoint();

    if (senderEndpoint == null) {
      throw new Fault(new org.apache.cxf.common.i18n.Message("ENDPOINT_NOT_FOUND", BUNDLE));
    }

    BindingOperationInfo boi = exchange.getBindingOperationInfo();

    if (boi == null) {
      throw new Fault(new org.apache.cxf.common.i18n.Message("OPERATIONINFO_NOT_FOUND", BUNDLE));
    }

    Server srv = isColocated(registry.getServers(), senderEndpoint, boi);

    if (srv != null) {
      if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("Operation:" + boi.getName() + " dispatched as colocated call.");
      }

      InterceptorChain outChain = message.getInterceptorChain();
      outChain.abort();
      exchange.put(Bus.class, bus);
      message.put(COLOCATED, Boolean.TRUE);
      message.put(Message.WSDL_OPERATION, boi.getName());
      message.put(Message.WSDL_INTERFACE, boi.getBinding().getInterface().getName());
      invokeColocObserver(message, srv.getEndpoint());
      if (!exchange.isOneWay()) {
        invokeInboundChain(exchange, senderEndpoint);
      }
    } else {
      if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("Operation:" + boi.getName() + " dispatched as remote call.");
      }

      message.put(COLOCATED, Boolean.FALSE);
    }
  }
コード例 #5
0
  protected String getActionUri(Message message, boolean checkMessage) {
    BindingOperationInfo bop = message.getExchange().getBindingOperationInfo();
    if (bop == null || Boolean.TRUE.equals(bop.getProperty("operation.is.synthetic"))) {
      return null;
    }
    OperationInfo op = bop.getOperationInfo();
    if (op.isUnwrapped()) {
      op = ((UnwrappedOperationInfo) op).getWrappedOperation();
    }

    String actionUri = null;
    if (checkMessage) {
      actionUri = (String) message.get(ContextUtils.ACTION);
      if (actionUri == null) {
        actionUri = (String) message.get(SoapBindingConstants.SOAP_ACTION);
      }
    }
    if (actionUri != null) {
      return actionUri;
    }
    String opNamespace = getActionBaseUri(op);

    boolean inbound = !ContextUtils.isOutbound(message);
    boolean requestor = ContextUtils.isRequestor(message);
    boolean inMsg = requestor ^ inbound;
    if (ContextUtils.isFault(message)) {
      String faultName = getFaultNameFromMessage(message);
      actionUri = getActionFromFaultMessage(op, faultName);
    } else if (inMsg) {
      String explicitAction = getActionFromInputMessage(op);
      if (StringUtils.isEmpty(explicitAction)) {
        SoapOperationInfo soi = InternalContextUtils.getSoapOperationInfo(bop);
        explicitAction = soi == null ? null : soi.getAction();
      }

      if (!StringUtils.isEmpty(explicitAction)) {
        actionUri = explicitAction;
      } else if (null == op.getInputName()) {
        actionUri = addPath(opNamespace, op.getName().getLocalPart() + "Request");
      } else {
        actionUri = addPath(opNamespace, op.getInputName());
      }
    } else {
      String explicitAction = getActionFromOutputMessage(op);
      if (explicitAction != null) {
        actionUri = explicitAction;
      } else if (null == op.getOutputName()) {
        actionUri = addPath(opNamespace, op.getName().getLocalPart() + "Response");
      } else {
        actionUri = addPath(opNamespace, op.getOutputName());
      }
    }
    return actionUri;
  }
コード例 #6
0
 public void handleMessage(Message message) throws Fault {
   BindingOperationInfo bop = message.getExchange().getBindingOperationInfo();
   if (bop == null || !bindingName.equals(bop.getBinding().getName())) {
     return;
   }
   Object o = message.getContent(soapMsgClass);
   if (o != null) {
     doFromSoapMessage(message, o);
   } else if (DataSource.class.isAssignableFrom(type)) {
     doDataSource(message);
   }
 }
コード例 #7
0
  public void handleMessage(Message message) {
    try {
      NSStack nsStack = new NSStack();
      nsStack.push();

      BindingOperationInfo operation =
          (BindingOperationInfo) message.getExchange().get(BindingOperationInfo.class.getName());

      assert operation.getName() != null;

      XMLStreamWriter xmlWriter = getXMLStreamWriter(message);

      List<MessagePartInfo> parts = null;

      if (!isRequestor(message)) {
        parts = operation.getOutput().getMessageParts();
        addOperationNode(nsStack, message, xmlWriter, true, operation);
      } else {
        parts = operation.getInput().getMessageParts();
        addOperationNode(nsStack, message, xmlWriter, false, operation);
      }

      MessageContentsList objs = MessageContentsList.getContentsList(message);
      if (objs == null) {
        return;
      }

      for (MessagePartInfo part : parts) {
        if (objs.hasValue(part)) {
          Object o = objs.get(part);
          if (o == null) {
            // WSI-BP R2211 - RPC/Lit parts are not allowed to be xsi:nil
            throw new Fault(
                new org.apache.cxf.common.i18n.Message(
                    "BP_2211_RPCLIT_CANNOT_BE_NULL", LOG, part.getConcreteName()));
          }
          // WSI-BP R2737  -RPC/LIG part name space is empty
          // part.setConcreteName(new QName("", part.getConcreteName().getLocalPart()));
        }
      }
      writeParts(message, message.getExchange(), operation, objs, parts);

      // Finishing the writing.
      xmlWriter.writeEndElement();
    } catch (XMLStreamException e) {
      throw new Fault(e);
    }
  }
コード例 #8
0
  private SoapMessage setUpMessage() throws Exception {

    SoapMessage message = new SoapMessage(new MessageImpl());
    Exchange exchange = new ExchangeImpl();
    BindingOperationInfo bop =
        setUpBindingOperationInfo(
            "http://foo/bar", "opReq", "opResp", SEI.class.getMethod("op", new Class[0]));
    SoapOperationInfo sop = new SoapOperationInfo();
    sop.setAction("http://foo/bar/SEI/opReq");
    bop.addExtensor(sop);
    exchange.put(BindingOperationInfo.class, bop);
    message.setExchange(exchange);
    message.put(Message.REQUESTOR_ROLE, Boolean.TRUE);

    control.replay();
    return message;
  }
コード例 #9
0
  private void initializeBindingOperation(SoapBindingInfo bi, BindingOperationInfo boi) {
    SoapOperationInfo soi = new SoapOperationInfo();

    SoapOperation soapOp =
        SOAPBindingUtil.getSoapOperation(boi.getExtensors(ExtensibilityElement.class));

    if (soapOp != null) {
      String action = soapOp.getSoapActionURI();
      if (action == null) {
        action = "";
      }
      soi.setAction(action);
      soi.setStyle(soapOp.getStyle());
    }

    boi.addExtensor(soi);

    if (boi.getInput() != null) {
      initializeMessage(bi, boi, boi.getInput());
    }

    if (boi.getOutput() != null) {
      initializeMessage(bi, boi, boi.getOutput());
    }
  }
コード例 #10
0
ファイル: DefaultCxfBinding.java プロジェクト: hayden74/camel
  protected MessageContentsList getResponsePayloadList(
      org.apache.cxf.message.Exchange exchange, List<Source> elements) {
    BindingOperationInfo boi = exchange.getBindingOperationInfo();

    if (boi.isUnwrapped()) {
      boi = boi.getWrappedOperation();
      exchange.put(BindingOperationInfo.class, boi);
    }

    MessageContentsList answer = new MessageContentsList();

    int i = 0;
    if (boi.getOutput() != null) {
      for (MessagePartInfo partInfo : boi.getOutput().getMessageParts()) {
        if (elements != null && elements.size() > i) {
          answer.put(partInfo, elements.get(i++));
        }
      }
    }

    return answer;
  }
コード例 #11
0
 private void resetPartTypes(BindingOperationInfo bop) {
   if (bop.isUnwrapped()) {
     bop = bop.getWrappedOperation();
   }
   if (bop.isUnwrappedCapable()) {
     resetPartTypeClass(bop.getWrappedOperation().getOperationInfo().getInput());
     resetPartTypeClass(bop.getWrappedOperation().getOperationInfo().getOutput());
     resetPartTypeClass(bop.getWrappedOperation().getInput());
     resetPartTypeClass(bop.getWrappedOperation().getOutput());
   }
   resetPartTypeClass(bop.getOperationInfo().getInput());
   resetPartTypeClass(bop.getOperationInfo().getOutput());
   resetPartTypeClass(bop.getInput());
   resetPartTypeClass(bop.getOutput());
 }
コード例 #12
0
  @Test
  public void testRequestorOutboundDispatchedSoapAction() throws Exception {
    SoapMessage message = setUpMessage();
    BindingOperationInfo dbop =
        setUpBindingOperationInfo(
            "http://foo/bar/d", "opDReq", "opDResp", SEI.class.getMethod("op", new Class[0]));
    SoapOperationInfo soi = new SoapOperationInfo();
    soi.setAction("http://foo/bar/d/SEI/opDReq");
    dbop.addExtensor(soi);

    BindingOperationInfo bop = message.getExchange().get(BindingOperationInfo.class);
    bop.setProperty("dispatchToOperation", dbop);

    interceptor.handleMessage(message);
    control.verify();

    Map<String, List<String>> reqHeaders =
        CastUtils.cast((Map<?, ?>) message.get(Message.PROTOCOL_HEADERS));
    assertNotNull(reqHeaders);
    List<String> soapaction = reqHeaders.get("soapaction");
    assertTrue(null != soapaction && soapaction.size() == 1);
    assertEquals("\"http://foo/bar/d/SEI/opDReq\"", soapaction.get(0));
  }
コード例 #13
0
  protected Server isColocated(List<Server> servers, Endpoint endpoint, BindingOperationInfo boi) {
    if (servers != null) {
      Service senderService = endpoint.getService();
      EndpointInfo senderEI = endpoint.getEndpointInfo();
      for (Server s : servers) {
        Endpoint receiverEndpoint = s.getEndpoint();
        Service receiverService = receiverEndpoint.getService();
        EndpointInfo receiverEI = receiverEndpoint.getEndpointInfo();
        if (receiverService.getName().equals(senderService.getName())
            && receiverEI.getName().equals(senderEI.getName())) {
          // Check For Operation Match.
          BindingOperationInfo receiverOI = receiverEI.getBinding().getOperation(boi.getName());
          if (receiverOI != null && isCompatibleOperationInfo(boi, receiverOI)) {
            return s;
          }
        }
      }
    }

    return null;
  }
コード例 #14
0
ファイル: DefaultCxfBinding.java プロジェクト: hayden74/camel
  /** This method is called by {@link CxfConsumer}. */
  public void populateExchangeFromCxfRequest(
      org.apache.cxf.message.Exchange cxfExchange, Exchange camelExchange) {

    Method method = null;
    QName operationName = null;
    ExchangePattern mep = ExchangePattern.InOut;

    // extract binding operation information
    BindingOperationInfo boi =
        camelExchange.getProperty(BindingOperationInfo.class.getName(), BindingOperationInfo.class);
    if (boi != null) {
      Service service = cxfExchange.get(Service.class);
      if (service != null) {
        MethodDispatcher md = (MethodDispatcher) service.get(MethodDispatcher.class.getName());
        if (md != null) {
          method = md.getMethod(boi);
        }
      }

      if (boi.getOperationInfo().isOneWay()) {
        mep = ExchangePattern.InOnly;
      }

      operationName = boi.getName();
    }

    // set operation name in header
    if (operationName != null) {
      camelExchange
          .getIn()
          .setHeader(CxfConstants.OPERATION_NAMESPACE, boi.getName().getNamespaceURI());
      camelExchange.getIn().setHeader(CxfConstants.OPERATION_NAME, boi.getName().getLocalPart());
      if (LOG.isTraceEnabled()) {
        LOG.trace(
            "Set IN header: {}={}",
            CxfConstants.OPERATION_NAMESPACE,
            boi.getName().getNamespaceURI());
        LOG.trace(
            "Set IN header: {}={}", CxfConstants.OPERATION_NAME, boi.getName().getLocalPart());
      }
    } else if (method != null) {
      camelExchange.getIn().setHeader(CxfConstants.OPERATION_NAME, method.getName());
      if (LOG.isTraceEnabled()) {
        LOG.trace("Set IN header: {}={}", CxfConstants.OPERATION_NAME, method.getName());
      }
    }

    // set message exchange pattern
    camelExchange.setPattern(mep);
    LOG.trace("Set exchange MEP: {}", mep);

    // propagate headers
    Message cxfMessage = cxfExchange.getInMessage();
    propagateHeadersFromCxfToCamel(cxfMessage, camelExchange.getIn(), camelExchange);

    // propagate the security subject from CXF security context
    SecurityContext securityContext = cxfMessage.get(SecurityContext.class);
    if (securityContext instanceof LoginSecurityContext
        && ((LoginSecurityContext) securityContext).getSubject() != null) {
      camelExchange
          .getIn()
          .getHeaders()
          .put(Exchange.AUTHENTICATION, ((LoginSecurityContext) securityContext).getSubject());
    } else if (securityContext != null && securityContext.getUserPrincipal() != null) {
      Subject subject = new Subject();
      subject.getPrincipals().add(securityContext.getUserPrincipal());
      camelExchange.getIn().getHeaders().put(Exchange.AUTHENTICATION, subject);
    }

    // Propagating properties from CXF Exchange to Camel Exchange has an
    // side effect of copying reply side stuff when the producer is retried.
    // So, we do not want to do this.
    // camelExchange.getProperties().putAll(cxfExchange);

    // propagate request context
    Object value = cxfMessage.get(Client.REQUEST_CONTEXT);
    if (value != null
        && !headerFilterStrategy.applyFilterToExternalHeaders(
            Client.REQUEST_CONTEXT, value, camelExchange)) {
      camelExchange.getIn().setHeader(Client.REQUEST_CONTEXT, value);
      LOG.trace("Populate context from CXF message {} value={}", Client.REQUEST_CONTEXT, value);
    }

    // setup the charset from content-type header
    setCharsetWithContentType(camelExchange);

    // set body
    Object body =
        DefaultCxfBinding.getContentFromCxf(
            cxfMessage,
            camelExchange.getProperty(CxfConstants.DATA_FORMAT_PROPERTY, DataFormat.class));
    if (body != null) {
      camelExchange.getIn().setBody(body);
    }

    // propagate attachments if the data format is not POJO
    if (cxfMessage.getAttachments() != null
        && !camelExchange
            .getProperty(CxfConstants.DATA_FORMAT_PROPERTY, DataFormat.class)
            .equals(DataFormat.POJO)) {
      for (Attachment attachment : cxfMessage.getAttachments()) {
        camelExchange.getIn().addAttachment(attachment.getId(), attachment.getDataHandler());
      }
    }
  }
コード例 #15
0
  public void handleMessage(Message message) throws Fault {
    if (isGET(message)) {
      LOG.info("JbiMessageInInterceptor skipped in HTTP GET method");
      return;
    }
    XMLStreamReader xsr = message.getContent(XMLStreamReader.class);

    DepthXMLStreamReader reader = new DepthXMLStreamReader(xsr);

    Endpoint ep = message.getExchange().get(Endpoint.class);
    BindingInfo binding = ep.getEndpointInfo().getBinding();
    if (!(binding instanceof NMRBindingInfo)) {
      throw new IllegalStateException(
          new org.apache.cxf.common.i18n.Message("NEED_JBIBINDING", BUNDLE).toString());
    }

    if (!StaxUtils.toNextElement(reader)) {
      throw new Fault(new org.apache.cxf.common.i18n.Message("NO_OPERATION_ELEMENT", BUNDLE));
    }

    Exchange ex = message.getExchange();
    QName startQName = reader.getName();

    // handling jbi fault message
    if (startQName.getLocalPart().equals(NMRFault.NMR_FAULT_ROOT)) {
      message.getInterceptorChain().abort();

      if (ep.getInFaultObserver() != null) {
        ep.getInFaultObserver().onMessage(message);
        return;
      }
    }

    // handling xml normal inbound message
    if (!startQName.equals(NMRConstants.JBI_WRAPPER_MESSAGE)) {
      throw new Fault(new org.apache.cxf.common.i18n.Message("NO_JBI_MESSAGE_ELEMENT", BUNDLE));
    }

    try {
      BindingOperationInfo bop = ex.get(BindingOperationInfo.class);
      DataReader<XMLStreamReader> dr = getDataReader(message);
      List<Object> parameters = new ArrayList<Object>();
      reader.next();
      BindingMessageInfo messageInfo = !isRequestor(message) ? bop.getInput() : bop.getOutput();
      message.put(MessageInfo.class, messageInfo.getMessageInfo());
      for (MessagePartInfo part : messageInfo.getMessageParts()) {
        if (!StaxUtils.skipToStartOfElement(reader)) {
          throw new Fault(new org.apache.cxf.common.i18n.Message("NOT_ENOUGH_PARTS", BUNDLE));
        }
        startQName = reader.getName();
        if (!startQName.equals(NMRConstants.JBI_WRAPPER_PART)) {
          throw new Fault(new org.apache.cxf.common.i18n.Message("NO_JBI_PART_ELEMENT", BUNDLE));
        }
        if (part.isElement()) {
          reader.next();
          if (!StaxUtils.toNextElement(reader)) {
            throw new Fault(
                new org.apache.cxf.common.i18n.Message("EXPECTED_ELEMENT_IN_PART", BUNDLE));
          }
        }
        parameters.add(dr.read(part, reader));
        // skip end element
        if (part.isElement()) {
          reader.next();
        }
      }
      int ev = reader.getEventType();
      while (ev != XMLStreamConstants.END_ELEMENT
          && ev != XMLStreamConstants.START_ELEMENT
          && ev != XMLStreamConstants.END_DOCUMENT) {
        ev = reader.next();
      }
      message.setContent(List.class, parameters);
    } catch (XMLStreamException e) {
      throw new Fault(new org.apache.cxf.common.i18n.Message("STAX_READ_EXC", BUNDLE), e);
    }
  }
コード例 #16
0
ファイル: DefaultCxfBinding.java プロジェクト: hayden74/camel
  protected static List<Source> getPayloadBodyElements(Message message, Map<String, String> nsMap) {
    // take the namespace attribute from soap envelop
    Map<String, String> bodyNC = CastUtils.cast((Map<?, ?>) message.get("soap.body.ns.context"));
    if (bodyNC != null) {
      // if there is no Node and the addNamespaceContext option is enabled, this map is available
      nsMap.putAll(bodyNC);
    } else {
      Document soapEnv = (Document) message.getContent(Node.class);
      if (soapEnv != null) {
        NamedNodeMap attrs = soapEnv.getFirstChild().getAttributes();
        for (int i = 0; i < attrs.getLength(); i++) {
          Node node = attrs.item(i);
          if (!node.getNodeValue().equals(Soap11.SOAP_NAMESPACE)
              && !node.getNodeValue().equals(Soap12.SOAP_NAMESPACE)) {
            nsMap.put(node.getLocalName(), node.getNodeValue());
          }
        }
      }
    }
    MessageContentsList inObjects = MessageContentsList.getContentsList(message);
    if (inObjects == null) {
      return new ArrayList<Source>(0);
    }
    org.apache.cxf.message.Exchange exchange = message.getExchange();
    BindingOperationInfo boi = exchange.getBindingOperationInfo();

    OperationInfo op = boi.getOperationInfo();

    if (boi.isUnwrapped()) {
      op = boi.getWrappedOperation().getOperationInfo();
    }

    List<MessagePartInfo> partInfos = null;
    boolean client = Boolean.TRUE.equals(message.get(Message.REQUESTOR_ROLE));
    if (client) {
      // it is a response
      partInfos = op.getOutput().getMessageParts();

    } else {
      // it is a request
      partInfos = op.getInput().getMessageParts();
    }

    List<Source> answer = new ArrayList<Source>();

    for (MessagePartInfo partInfo : partInfos) {
      if (!inObjects.hasValue(partInfo)) {
        continue;
      }

      Object part = inObjects.get(partInfo);

      if (part instanceof Holder) {
        part = ((Holder<?>) part).value;
      }

      if (part instanceof Source) {
        Element element = null;
        if (part instanceof DOMSource) {
          element = getFirstElement(((DOMSource) part).getNode());
        }

        if (element != null) {
          addNamespace(element, nsMap);
          answer.add(new DOMSource(element));
        } else {
          answer.add((Source) part);
        }

        if (LOG.isTraceEnabled()) {
          LOG.trace("Extract body element {}", element == null ? "null" : getXMLString(element));
        }
      } else if (part instanceof Element) {
        addNamespace((Element) part, nsMap);
        answer.add(new DOMSource((Element) part));
      } else {
        if (LOG.isDebugEnabled()) {
          LOG.debug("Unhandled part type '{}'", part.getClass());
        }
      }
    }

    return answer;
  }
コード例 #17
0
  public BindingInfo createBindingInfo(ServiceInfo si, String bindingid, Object conf) {
    SoapBindingConfiguration config;
    if (conf instanceof SoapBindingConfiguration) {
      config = (SoapBindingConfiguration) conf;
    } else {
      config = new SoapBindingConfiguration();
    }
    if (WSDLConstants.NS_SOAP12.equals(bindingid)
        || WSDLConstants.NS_SOAP12_HTTP_BINDING.equals(bindingid)) {
      config.setVersion(Soap12.getInstance());
      config.setTransportURI(WSDLConstants.NS_SOAP_HTTP_TRANSPORT);
    }
    SoapBindingInfo info = new SoapBindingInfo(si, bindingid, config.getVersion());

    info.setName(config.getBindingName(si));
    info.setStyle(config.getStyle());

    info.setTransportURI(config.getTransportURI());

    if (config.isMtomEnabled()) {
      info.setProperty(Message.MTOM_ENABLED, Boolean.TRUE);
    }

    for (OperationInfo op : si.getInterface().getOperations()) {
      SoapOperationInfo sop = new SoapOperationInfo();
      sop.setAction(config.getSoapAction(op));
      sop.setStyle(config.getStyle(op));

      BindingOperationInfo bop =
          info.buildOperation(op.getName(), op.getInputName(), op.getOutputName());

      bop.addExtensor(sop);

      info.addOperation(bop);

      BindingMessageInfo bInput = bop.getInput();
      if (bInput != null) {
        MessageInfo input = null;
        BindingMessageInfo unwrappedMsg = bInput;
        if (bop.isUnwrappedCapable()) {
          input = bop.getOperationInfo().getUnwrappedOperation().getInput();
          unwrappedMsg = bop.getUnwrappedOperation().getInput();
        } else {
          input = bop.getOperationInfo().getInput();
        }
        setupHeaders(bop, bInput, unwrappedMsg, input, config);
      }

      BindingMessageInfo bOutput = bop.getOutput();
      if (bOutput != null) {
        MessageInfo output = null;
        BindingMessageInfo unwrappedMsg = bOutput;
        if (bop.isUnwrappedCapable()) {
          output = bop.getOperationInfo().getUnwrappedOperation().getOutput();
          unwrappedMsg = bop.getUnwrappedOperation().getOutput();
        } else {
          output = bop.getOperationInfo().getOutput();
        }
        setupHeaders(bop, bOutput, unwrappedMsg, output, config);
      }
    }

    try {
      createSoapBinding(info);
    } catch (WSDLException e) {
      e.printStackTrace();
    }

    return info;
  }
コード例 #18
0
 protected boolean isCompatibleOperationInfo(
     BindingOperationInfo sender, BindingOperationInfo receiver) {
   return ColocUtil.isCompatibleOperationInfo(
       sender.getOperationInfo(), receiver.getOperationInfo());
 }
コード例 #19
0
  public Binding createBinding(BindingInfo binding) {
    // TODO what about the mix style/use?

    // The default style should be doc-lit wrapped.
    String parameterStyle = SoapBindingConstants.PARAMETER_STYLE_WRAPPED;
    String bindingStyle = SoapBindingConstants.BINDING_STYLE_DOC;

    boolean hasWrapped = false;

    org.apache.cxf.binding.soap.SoapBinding sb = null;
    SoapVersion version = null;
    if (binding instanceof SoapBindingInfo) {
      SoapBindingInfo sbi = (SoapBindingInfo) binding;
      version = sbi.getSoapVersion();
      sb = new org.apache.cxf.binding.soap.SoapBinding(binding, version);
      // Service wide style
      if (!StringUtils.isEmpty(sbi.getStyle())) {
        bindingStyle = sbi.getStyle();
      }

      boolean hasRPC = false;
      boolean hasDoc = false;

      // Operation wide style, what to do with the mixed style/use?
      for (BindingOperationInfo boi : sbi.getOperations()) {
        String st = sbi.getStyle(boi.getOperationInfo());
        if (st != null) {
          bindingStyle = st;
          if (SoapBindingConstants.BINDING_STYLE_RPC.equalsIgnoreCase(st)) {
            hasRPC = true;
          } else {
            hasDoc = true;
          }
        }
        if (boi.getUnwrappedOperation() == null) {
          parameterStyle = SoapBindingConstants.PARAMETER_STYLE_BARE;
        } else {
          hasWrapped = true;
        }
      }

      if (Boolean.TRUE.equals(binding.getService().getProperty("soap.force.doclit.bare"))) {
        hasDoc = true;
        hasRPC = false;
        parameterStyle = SoapBindingConstants.PARAMETER_STYLE_BARE;
        bindingStyle = SoapBindingConstants.BINDING_STYLE_DOC;
      }
      if (hasRPC && hasDoc) {
        throw new RuntimeException(
            "WSI-BP prohibits RPC and Document style " + "operations in same service.");
      }

      // jms
      if (sbi.getTransportURI().equals(SoapJMSConstants.SOAP_JMS_SPECIFICIATION_TRANSPORTID)) {
        sb.getInInterceptors().add(new SoapJMSInInterceptor());
      }
    } else {
      throw new RuntimeException(
          "Can not initialize SoapBinding, BindingInfo is not SoapBindingInfo");
    }

    sb.getOutFaultInterceptors().add(new StaxOutInterceptor());
    sb.getOutFaultInterceptors().add(new SoapOutInterceptor(getBus()));

    sb.getInInterceptors().add(new AttachmentInInterceptor());
    sb.getInInterceptors().add(new StaxInInterceptor());
    sb.getInInterceptors().add(new SoapActionInInterceptor());

    sb.getOutInterceptors().add(new AttachmentOutInterceptor());
    sb.getOutInterceptors().add(new StaxOutInterceptor());
    sb.getOutInterceptors().add(SoapHeaderOutFilterInterceptor.INSTANCE);

    if (SoapBindingConstants.BINDING_STYLE_RPC.equalsIgnoreCase(bindingStyle)) {
      sb.getInInterceptors().add(new RPCInInterceptor());
      sb.getOutInterceptors().add(new RPCOutInterceptor());
    } else if (SoapBindingConstants.BINDING_STYLE_DOC.equalsIgnoreCase(bindingStyle)
        && SoapBindingConstants.PARAMETER_STYLE_BARE.equalsIgnoreCase(parameterStyle)) {
      // sb.getInInterceptors().add(new BareInInterceptor());
      sb.getInInterceptors().add(new DocLiteralInInterceptor());
      if (hasWrapped) {
        sb.getOutInterceptors().add(new WrappedOutInterceptor());
      }
      sb.getOutInterceptors().add(new BareOutInterceptor());
    } else {
      // sb.getInInterceptors().add(new WrappedInInterceptor());
      sb.getInInterceptors().add(new DocLiteralInInterceptor());
      sb.getOutInterceptors().add(new WrappedOutInterceptor());
      sb.getOutInterceptors().add(new BareOutInterceptor());
    }
    sb.getInInterceptors().add(new SoapHeaderInterceptor());

    sb.getInInterceptors().add(new ReadHeadersInterceptor(getBus(), version));
    sb.getInInterceptors().add(new StartBodyInterceptor());
    sb.getInInterceptors().add(new CheckFaultInterceptor());
    sb.getInInterceptors().add(new MustUnderstandInterceptor());
    sb.getOutInterceptors().add(new SoapPreProtocolOutInterceptor());
    sb.getOutInterceptors().add(new SoapOutInterceptor(getBus()));
    sb.getOutFaultInterceptors().add(new SoapOutInterceptor(getBus()));
    sb.getOutFaultInterceptors().add(SoapHeaderOutFilterInterceptor.INSTANCE);

    // REVISIT: The phase interceptor chain seems to freak out if this added
    // first. Not sure what the deal is at the moment, I suspect the
    // ordering algorithm needs to be improved
    sb.getInInterceptors().add(new URIMappingInterceptor());

    if (version.getVersion() == 1.1) {
      sb.getInFaultInterceptors().add(new Soap11FaultInInterceptor());
      sb.getOutFaultInterceptors().add(new Soap11FaultOutInterceptor());
    } else if (version.getVersion() == 1.2) {
      sb.getInFaultInterceptors().add(new Soap12FaultInInterceptor());
      sb.getOutFaultInterceptors().add(new Soap12FaultOutInterceptor());
    }

    if (binding.getService() != null) {
      for (EndpointInfo ei : binding.getService().getEndpoints()) {
        if (ei.getAddress() != null && ei.getAddress().startsWith("soap.udp")) {
          setupUDP(sb, ei);
        }
      }
    }

    return sb;
  }
コード例 #20
0
  private void createSoapBinding(final SoapBindingInfo bi) throws WSDLException {
    boolean isSoap12 = bi.getSoapVersion() instanceof Soap12;
    Bus bs = getBus();
    WSDLManager m = bs.getExtension(WSDLManager.class);
    ExtensionRegistry extensionRegistry = m.getExtensionRegistry();

    SoapBinding soapBinding = SOAPBindingUtil.createSoapBinding(extensionRegistry, isSoap12);
    soapBinding.setStyle(bi.getStyle());
    soapBinding.setTransportURI(bi.getTransportURI());
    bi.addExtensor(soapBinding);

    for (BindingOperationInfo b : bi.getOperations()) {
      for (BindingFaultInfo faultInfo : b.getFaults()) {
        SoapFault soapFault = SOAPBindingUtil.createSoapFault(extensionRegistry, isSoap12);
        soapFault.setUse("literal");
        soapFault.setName(faultInfo.getFaultInfo().getFaultName().getLocalPart());
        faultInfo.addExtensor(soapFault);
      }
      SoapOperationInfo soi = b.getExtensor(SoapOperationInfo.class);

      SoapOperation soapOperation =
          SOAPBindingUtil.createSoapOperation(extensionRegistry, isSoap12);
      soapOperation.setSoapActionURI(soi.getAction());
      soapOperation.setStyle(soi.getStyle());
      boolean isRpc = "rpc".equals(soapOperation.getStyle());

      b.addExtensor(soapOperation);

      if (b.getInput() != null) {
        List<String> bodyParts = null;
        List<SoapHeaderInfo> headerInfos = b.getInput().getExtensors(SoapHeaderInfo.class);
        if (headerInfos != null && headerInfos.size() > 0) {
          bodyParts = new ArrayList<String>();
          for (MessagePartInfo part : b.getInput().getMessageParts()) {
            bodyParts.add(part.getName().getLocalPart());
          }

          for (SoapHeaderInfo headerInfo : headerInfos) {
            SoapHeader soapHeader =
                SOAPBindingUtil.createSoapHeader(extensionRegistry, BindingInput.class, isSoap12);
            soapHeader.setMessage(b.getInput().getMessageInfo().getName());
            soapHeader.setPart(headerInfo.getPart().getName().getLocalPart());
            soapHeader.setUse("literal");
            bodyParts.remove(headerInfo.getPart().getName().getLocalPart());
            headerInfo.getPart().setProperty(HEADER, true);
            b.getInput().addExtensor(soapHeader);
          }
        }
        SoapBody body =
            SOAPBindingUtil.createSoapBody(extensionRegistry, BindingInput.class, isSoap12);
        body.setUse("literal");
        if (isRpc) {
          body.setNamespaceURI(b.getName().getNamespaceURI());
        }

        if (bodyParts != null) {
          body.setParts(bodyParts);
        }

        b.getInput().addExtensor(body);
      }

      if (b.getOutput() != null) {
        List<String> bodyParts = null;
        List<SoapHeaderInfo> headerInfos = b.getOutput().getExtensors(SoapHeaderInfo.class);
        if (headerInfos != null && headerInfos.size() > 0) {
          bodyParts = new ArrayList<String>();
          for (MessagePartInfo part : b.getOutput().getMessageParts()) {
            bodyParts.add(part.getName().getLocalPart());
          }
          for (SoapHeaderInfo headerInfo : headerInfos) {
            SoapHeader soapHeader =
                SOAPBindingUtil.createSoapHeader(extensionRegistry, BindingOutput.class, isSoap12);
            soapHeader.setMessage(b.getOutput().getMessageInfo().getName());
            soapHeader.setPart(headerInfo.getPart().getName().getLocalPart());
            soapHeader.setUse("literal");
            bodyParts.remove(headerInfo.getPart().getName().getLocalPart());
            b.getOutput().addExtensor(soapHeader);
          }
        }
        SoapBody body =
            SOAPBindingUtil.createSoapBody(extensionRegistry, BindingOutput.class, isSoap12);
        body.setUse("literal");
        if (isRpc) {
          body.setNamespaceURI(b.getName().getNamespaceURI());
        }

        if (bodyParts != null) {
          body.setParts(bodyParts);
        }

        b.getOutput().addExtensor(body);
      }
    }
  }
コード例 #21
0
  private void addOutOfBandParts(
      final BindingOperationInfo bop,
      final javax.wsdl.Message msg,
      final SchemaCollection schemas,
      boolean isInput,
      final String partName) {
    MessageInfo minfo = null;
    MessageInfo.Type type;

    int nextId = 0;
    minfo = bop.getOperationInfo().getInput();
    if (minfo != null) {
      for (MessagePartInfo part : minfo.getMessageParts()) {
        if (part.getIndex() >= nextId) {
          nextId = part.getIndex() + 1;
        }
      }
    }
    minfo = bop.getOperationInfo().getOutput();
    if (minfo != null) {
      for (MessagePartInfo part : minfo.getMessageParts()) {
        if (part.getIndex() >= nextId) {
          nextId = part.getIndex() + 1;
        }
      }
    }

    if (isInput) {
      type = MessageInfo.Type.INPUT;
      minfo = bop.getOperationInfo().getInput();
    } else {
      type = MessageInfo.Type.OUTPUT;
      minfo = bop.getOperationInfo().getOutput();
    }

    if (minfo == null) {
      minfo = new MessageInfo(null, type, msg.getQName());
    }
    buildMessage(minfo, msg, schemas, nextId, partName);

    // for wrapped style
    OperationInfo unwrapped = bop.getOperationInfo().getUnwrappedOperation();
    if (unwrapped == null) {
      return;
    }

    nextId = 0;
    minfo = unwrapped.getInput();
    if (minfo != null) {
      for (MessagePartInfo part : minfo.getMessageParts()) {
        if (part.getIndex() >= nextId) {
          nextId = part.getIndex() + 1;
        }
      }
    }
    minfo = unwrapped.getOutput();
    if (minfo != null) {
      for (MessagePartInfo part : minfo.getMessageParts()) {
        if (part.getIndex() >= nextId) {
          nextId = part.getIndex() + 1;
        }
      }
    }

    if (isInput) {
      minfo = unwrapped.getInput();
      type = MessageInfo.Type.INPUT;
    } else {
      minfo = unwrapped.getOutput();
      type = MessageInfo.Type.OUTPUT;
    }

    if (minfo == null) {
      minfo = new MessageInfo(unwrapped, type, msg.getQName());
    }
    buildMessage(minfo, msg, schemas, nextId, partName);
  }
コード例 #22
0
ファイル: ClientFaultConverter.java プロジェクト: Jutten/cxf
  protected void processFaultDetail(Fault fault, Message msg) {
    Element exDetail = (Element) DOMUtils.getChild(fault.getDetail(), Node.ELEMENT_NODE);
    if (exDetail == null) {
      return;
    }
    QName qname = new QName(exDetail.getNamespaceURI(), exDetail.getLocalName());
    FaultInfo faultWanted = null;
    MessagePartInfo part = null;
    BindingOperationInfo boi = msg.getExchange().get(BindingOperationInfo.class);
    if (boi == null) {
      return;
    }
    if (boi.isUnwrapped()) {
      boi = boi.getWrappedOperation();
    }
    for (FaultInfo faultInfo : boi.getOperationInfo().getFaults()) {
      for (MessagePartInfo mpi : faultInfo.getMessageParts()) {
        if (qname.equals(mpi.getConcreteName())) {
          faultWanted = faultInfo;
          part = mpi;
          break;
        }
      }
      if (faultWanted != null) {
        break;
      }
    }
    if (faultWanted == null) {
      // did not find it using the proper qualified names, we'll try again with just the localpart
      for (FaultInfo faultInfo : boi.getOperationInfo().getFaults()) {
        for (MessagePartInfo mpi : faultInfo.getMessageParts()) {
          if (qname.getLocalPart().equals(mpi.getConcreteName().getLocalPart())) {
            faultWanted = faultInfo;
            part = mpi;
            break;
          }
        }
        if (faultWanted != null) {
          break;
        }
      }
    }
    if (faultWanted == null) {
      return;
    }
    Service s = msg.getExchange().get(Service.class);
    DataBinding dataBinding = s.getDataBinding();

    Object e = null;
    if (isDOMSupported(dataBinding)) {
      DataReader<Node> reader = this.getNodeDataReader(msg);
      reader.setProperty(DataReader.FAULT, fault);
      e = reader.read(part, exDetail);
    } else {
      DataReader<XMLStreamReader> reader = this.getDataReader(msg);
      XMLStreamReader xsr = new W3CDOMStreamReader(exDetail);
      try {
        xsr.nextTag();
      } catch (XMLStreamException e1) {
        throw new Fault(e1);
      }
      reader.setProperty(DataReader.FAULT, fault);
      e = reader.read(part, xsr);
    }

    if (!(e instanceof Exception)) {

      try {
        Class<?> exClass = faultWanted.getProperty(Class.class.getName(), Class.class);
        if (exClass == null) {
          return;
        }
        if (e == null) {
          Constructor<?> constructor = exClass.getConstructor(new Class[] {String.class});
          e = constructor.newInstance(new Object[] {fault.getMessage()});
        } else {

          try {
            Constructor<?> constructor = getConstructor(exClass, e);
            e = constructor.newInstance(new Object[] {fault.getMessage(), e});
          } catch (NoSuchMethodException e1) {
            // Use reflection to convert fault bean to exception
            e = convertFaultBean(exClass, e, fault);
          }
        }
        msg.setContent(Exception.class, e);
      } catch (Exception e1) {
        LogUtils.log(LOG, Level.INFO, "EXCEPTION_WHILE_CREATING_EXCEPTION", e1, e1.getMessage());
      }
    } else {
      if (fault.getMessage() != null) {
        Field f;
        try {
          f = Throwable.class.getDeclaredField("detailMessage");
          ReflectionUtil.setAccessible(f);
          f.set(e, fault.getMessage());
        } catch (Exception e1) {
          // ignore
        }
      }
      msg.setContent(Exception.class, e);
    }
  }
コード例 #23
0
  private void initializeMessage(
      SoapBindingInfo bi, BindingOperationInfo boi, BindingMessageInfo bmsg) {
    MessageInfo msg = bmsg.getMessageInfo();

    List<MessagePartInfo> messageParts = new ArrayList<MessagePartInfo>();
    messageParts.addAll(msg.getMessageParts());

    List<SoapHeader> headers =
        SOAPBindingUtil.getSoapHeaders(bmsg.getExtensors(ExtensibilityElement.class));
    if (headers != null) {
      for (SoapHeader header : headers) {
        SoapHeaderInfo headerInfo = new SoapHeaderInfo();
        headerInfo.setUse(header.getUse());
        if (StringUtils.isEmpty(header.getPart())) {
          throw new RuntimeException(
              "Problem with WSDL: soap:header element in operation "
                  + boi.getName().getLocalPart()
                  + " does not specify a part.");
        }
        MessagePartInfo part =
            msg.getMessagePart(new QName(msg.getName().getNamespaceURI(), header.getPart()));
        if (part != null
            && header.getMessage() != null
            && !part.getMessageInfo().getName().equals(header.getMessage())) {
          part = null;
          // out of band, let's find it
          for (MessagePartInfo mpi : msg.getOutOfBandParts()) {
            if (mpi.getName().getLocalPart().equals(header.getPart())
                && mpi.getMessageInfo().getName().equals(header.getMessage())) {
              part = mpi;
            }
          }
        }
        if (part != null) {
          headerInfo.setPart(part);
          messageParts.remove(part);
          bmsg.addExtensor(headerInfo);
        }
      }

      // Exclude the header parts from the message part list.
      bmsg.setMessageParts(messageParts);
    }

    SoapBodyInfo bodyInfo = new SoapBodyInfo();
    SoapBody soapBody = SOAPBindingUtil.getSoapBody(bmsg.getExtensors(ExtensibilityElement.class));

    List<?> parts = null;
    if (soapBody == null) {
      MIMEMultipartRelated mmr = bmsg.getExtensor(MIMEMultipartRelated.class);
      if (mmr != null) {
        parts = mmr.getMIMEParts();
      }
    } else {
      bmsg.addExtensor(soapBody);
      bodyInfo.setUse(soapBody.getUse());
      parts = soapBody.getParts();
    }

    // Initialize the body parts.
    List<MessagePartInfo> attParts = null;
    if (parts != null) {
      List<MessagePartInfo> bodyParts = new ArrayList<MessagePartInfo>();
      for (Iterator<?> itr = parts.iterator(); itr.hasNext(); ) {
        Object part = itr.next();
        if (part instanceof MIMEPart) {
          MIMEPart mpart = (MIMEPart) part;
          attParts = handleMimePart(mpart, attParts, msg, bmsg, bodyParts, messageParts);
        } else {
          addSoapBodyPart(msg, bodyParts, (String) part);
        }
      }
      bodyInfo.setParts(bodyParts);
      bodyInfo.setAttachments(attParts);
    } else {
      bodyInfo.setParts(messageParts);
    }

    bmsg.addExtensor(bodyInfo);
  }
コード例 #24
0
  @Override
  protected void writeParts(
      Message message,
      Exchange exchange,
      BindingOperationInfo operation,
      MessageContentsList objs,
      List<MessagePartInfo> parts) {
    // TODO Auto-generated method stub
    OutputStream out = message.getContent(OutputStream.class);
    XMLStreamWriter origXmlWriter = message.getContent(XMLStreamWriter.class);
    Service service = exchange.getService();
    XMLStreamWriter xmlWriter = origXmlWriter;
    CachingXmlEventWriter cache = null;

    Object en = message.getContextualProperty(OUT_BUFFERING);
    boolean allowBuffer = true;
    boolean buffer = false;
    if (en != null) {
      buffer = Boolean.TRUE.equals(en) || "true".equals(en);
      allowBuffer = !(Boolean.FALSE.equals(en) || "false".equals(en));
    }
    // need to cache the events in case validation fails or buffering is enabled
    if (buffer || (allowBuffer && shouldValidate(message) && !isRequestor(message))) {
      cache = new CachingXmlEventWriter();
      try {
        cache.setNamespaceContext(origXmlWriter.getNamespaceContext());
      } catch (XMLStreamException e) {
        // ignorable, will just get extra namespace decls
      }
      xmlWriter = cache;
      out = null;
    }

    if (out != null
        && writeToOutputStream(message, operation.getBinding(), service)
        && !MessageUtils.isTrue(message.getContextualProperty(DISABLE_OUTPUTSTREAM_OPTIMIZATION))) {
      if (xmlWriter != null) {
        try {
          xmlWriter.writeCharacters("");
          xmlWriter.flush();
        } catch (XMLStreamException e) {
          throw new Fault(e);
        }
      }

      DataWriter<OutputStream> osWriter = getDataWriter(message, service, OutputStream.class);

      for (MessagePartInfo part : parts) {
        if (objs.hasValue(part)) {
          Object o = objs.get(part);
          osWriter.write(o, part, out);
        }
      }
    } else {
      DataWriter<XMLStreamWriter> dataWriter = new CustomDataWriter(prismContext);

      for (MessagePartInfo part : parts) {
        if (objs.hasValue(part)) {
          Object o = objs.get(part);
          dataWriter.write(o, part, xmlWriter);
        }
      }
    }
    if (cache != null) {
      try {
        for (XMLEvent event : cache.getEvents()) {
          StaxUtils.writeEvent(event, origXmlWriter);
        }
      } catch (XMLStreamException e) {
        throw new Fault(e);
      }
    }
  }
コード例 #25
0
ファイル: DefaultCxfBinding.java プロジェクト: hayden74/camel
  /**
   * This method is called by {@link CxfConsumer} to populate a CXF response exchange from a Camel
   * exchange.
   */
  public void populateCxfResponseFromExchange(
      Exchange camelExchange, org.apache.cxf.message.Exchange cxfExchange) {

    if (cxfExchange.isOneWay()) {
      return;
    }

    // create response context
    Map<String, Object> responseContext = new HashMap<String, Object>();

    org.apache.camel.Message response;
    if (camelExchange.getPattern().isOutCapable()) {
      if (camelExchange.hasOut()) {
        response = camelExchange.getOut();
        LOG.trace("Get the response from the out message");
      } else { // Take the in message as a fall back
        response = camelExchange.getIn();
        LOG.trace("Get the response from the in message as a fallback");
      }
    } else {
      response = camelExchange.getIn();
      LOG.trace("Get the response from the in message");
    }

    // propagate response context
    Map<String, Object> camelHeaders = response.getHeaders();
    extractInvocationContextFromCamel(
        camelExchange, camelHeaders, responseContext, Client.RESPONSE_CONTEXT);

    propagateHeadersFromCamelToCxf(camelExchange, camelHeaders, cxfExchange, responseContext);
    // create out message
    Endpoint ep = cxfExchange.get(Endpoint.class);
    Message outMessage = ep.getBinding().createMessage();
    cxfExchange.setOutMessage(outMessage);

    DataFormat dataFormat =
        camelExchange.getProperty(CxfConstants.DATA_FORMAT_PROPERTY, DataFormat.class);

    // make sure the "requestor role" property does not get propagated as we do switch role
    responseContext.remove(Message.REQUESTOR_ROLE);

    outMessage.putAll(responseContext);

    // Do we still need to put the response context back like this
    outMessage.put(Client.RESPONSE_CONTEXT, responseContext);

    LOG.trace("Set out response context = {}", responseContext);

    // set body
    Object outBody = DefaultCxfBinding.getBodyFromCamel(response, dataFormat);

    if (outBody != null) {
      if (dataFormat == DataFormat.PAYLOAD) {
        CxfPayload<?> payload = (CxfPayload<?>) outBody;
        outMessage.setContent(
            List.class, getResponsePayloadList(cxfExchange, payload.getBodySources()));
        outMessage.put(Header.HEADER_LIST, payload.getHeaders());
      } else {
        if (responseContext.get(Header.HEADER_LIST) != null) {
          outMessage.put(Header.HEADER_LIST, responseContext.get(Header.HEADER_LIST));
        }

        MessageContentsList resList = null;
        // Create a new MessageContentsList to avoid OOM from the HolderOutInterceptor
        if (outBody instanceof List) {
          resList = new MessageContentsList((List<?>) outBody);
        } else if (outBody.getClass().isArray()) {
          resList = new MessageContentsList((Object[]) outBody);
        } else {
          resList = new MessageContentsList(outBody);
        }

        if (resList != null) {
          outMessage.setContent(List.class, resList);
          LOG.trace("Set Out CXF message content = {}", resList);
        }
      }
    } else if (!cxfExchange.isOneWay()
        && cxfExchange.getInMessage() != null
        && MessageUtils.isTrue(
            cxfExchange
                .getInMessage()
                .getContextualProperty("jaxws.provider.interpretNullAsOneway"))) {
      // treat this non-oneway call as oneway when the provider returns a null
      changeToOneway(cxfExchange);
      return;
    }

    // propagate attachments

    Set<Attachment> attachments = null;
    boolean isXop = Boolean.valueOf(camelExchange.getProperty(Message.MTOM_ENABLED, String.class));
    for (Map.Entry<String, DataHandler> entry :
        camelExchange.getOut().getAttachments().entrySet()) {
      if (attachments == null) {
        attachments = new HashSet<Attachment>();
      }
      AttachmentImpl attachment = new AttachmentImpl(entry.getKey(), entry.getValue());
      attachment.setXOP(isXop);
      attachments.add(attachment);
    }

    if (attachments != null) {
      outMessage.setAttachments(attachments);
    }

    BindingOperationInfo boi = cxfExchange.get(BindingOperationInfo.class);
    if (boi != null) {
      cxfExchange.put(BindingMessageInfo.class, boi.getOutput());
    }
  }