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);
        }
      }
    }
  }
  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);
    }
  }
 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);
   }
 }
  @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);
      }
    }
  }