org.apache.cxf.binding.Binding类的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(15.9k)|赞(0)|评价(0)|浏览(113)

本文整理了Java中org.apache.cxf.binding.Binding类的一些代码示例,展示了Binding类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Binding类的具体详情如下:
包路径:org.apache.cxf.binding.Binding
类名称:Binding

Binding介绍

[英]A Binding provides interceptors and message creation logic for a specific protocol binding.
[中]绑定为特定协议绑定提供拦截器和消息创建逻辑。

代码示例

代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws

public void handleMessage(Message message) throws Fault {
  W3CDOMStreamWriter domWriter = (W3CDOMStreamWriter)message.getContent(XMLStreamWriter.class);
  XMLStreamWriter origWriter = (XMLStreamWriter)message
    .get(LogicalHandlerOutInterceptor.ORIGINAL_WRITER);
  XMLStreamReader reader = (XMLStreamReader)message.get("LogicalHandlerInterceptor.INREADER");
  SOAPMessage origMessage = null;
  if (reader != null) {
      message.getInterceptorChain().abort();
      if (!message.getExchange().isOneWay()) {
        Endpoint e = message.getExchange().getEndpoint();
        Message responseMsg = new MessageImpl();
        responseMsg.setExchange(message.getExchange());
        responseMsg = e.getBinding().createMessage(responseMsg);
        MessageObserver observer = message.getExchange()
              .get(MessageObserver.class);
        if (observer != null) {

代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws

= ((JaxWsClientEndpointImpl)client.getEndpoint()).getFeatures();
  List<Feature> allFeatures;
  if (client.getBus().getFeatures() != null) {
    allFeatures = new ArrayList<>(endpointFeatures.size()
      + client.getBus().getFeatures().size());
    allFeatures.addAll(endpointFeatures);
    allFeatures.addAll(client.getBus().getFeatures());
  } else {
    allFeatures = endpointFeatures;
    client.getEndpoint().getBinding().getBindingInfo(), hasOpName);
if (findDispatchOp && !payloadOPMap.isEmpty()) {
  QName payloadElementName = null;
            client.getEndpoint().getBinding().getBindingInfo(), hasOpName);
      BindingOperationInfo dbop = client.getEndpoint().getBinding().getBindingInfo()
        .getOperation(dispatchedOpName);
      if (dbop != null) {
        opName = dispatchedOpName;

代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws

public void handleMessage(Message message) throws Fault {
  W3CDOMStreamWriter domWriter = (W3CDOMStreamWriter)message.getContent(XMLStreamWriter.class);
  XMLStreamWriter origWriter = (XMLStreamWriter)message
    .get(LogicalHandlerFaultOutInterceptor.ORIGINAL_WRITER);
  boolean requestor = isRequestor(message);
  XMLStreamReader reader = (XMLStreamReader)message.get("LogicalHandlerInterceptor.INREADER");
  SOAPMessage origMessage = null;
  if (reader != null) {
    FaultMode mode = message.get(FaultMode.class);
    Message faultMessage = exchange.getOutMessage();
    if (null == faultMessage) {
      faultMessage = new MessageImpl();
      faultMessage.setExchange(message.getExchange());
      faultMessage = exchange.getEndpoint().getBinding().createMessage(faultMessage);
    faultMessage.setContent(Exception.class, ex);
      faultMessage.put(FaultMode.class, mode);
    exchange.setOutMessage(null);
    exchange.setOutFaultMessage(faultMessage);

代码示例来源:origin: apache/cxf

public void handleMessage(Message message) throws Fault {
  String action = (String)message.get(SoapBindingConstants.SOAP_ACTION);
  if (action == null) {
    AddressingProperties inProps = (AddressingProperties)message
      .getContextualProperty(JAXWSAConstants.ADDRESSING_PROPERTIES_INBOUND);
    if (inProps != null && inProps.getAction() != null) {
      action = inProps.getAction().getValue();
    }
  }
  if ("http://schemas.xmlsoap.org/ws/2004/09/transfer/Get".equals(action)
    || "http://schemas.xmlsoap.org/ws/2004/09/mex/GetMetadata/Request".equals(action)) {
    message.remove(AssertionInfoMap.class.getName());
    Exchange ex = message.getExchange();
    Endpoint endpoint = createEndpoint(message);
    ex.put(Endpoint.class, endpoint);
    ex.put(Service.class, endpoint.getService());
    ex.put(org.apache.cxf.binding.Binding.class, endpoint.getBinding());
    ex.put(BindingOperationInfo.class,
        endpoint.getBinding().getBindingInfo()
          .getOperation(new QName("http://mex.ws.cxf.apache.org/", "Get2004")));
    ex.remove(BindingOperationInfo.class);
    message.put(MAPAggregator.ACTION_VERIFIED, Boolean.TRUE);
    message.getInterceptorChain().add(endpoint.getInInterceptors());
    message.getInterceptorChain().add(endpoint.getBinding().getInInterceptors());
  }
}

代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws

private void handleAbort(Message message, W3CDOMStreamWriter writer) {
  message.getInterceptorChain().abort();
  if (!message.getExchange().isOneWay()) {
    //server side inbound
    Endpoint e = message.getExchange().getEndpoint();
    Message responseMsg = new MessageImpl();
    responseMsg.setExchange(message.getExchange());
    responseMsg = e.getBinding().createMessage(responseMsg);
    message.getExchange().setOutMessage(responseMsg);
    XMLStreamReader reader = message.getContent(XMLStreamReader.class);
    if (reader == null && writer != null) {
      reader = StaxUtils.createXMLStreamReader(writer.getDocument());
    }
    InterceptorChain chain = OutgoingChainInterceptor
      .getOutInterceptorChain(message.getExchange());
    responseMsg.setInterceptorChain(chain);
    responseMsg.put("LogicalHandlerInterceptor.INREADER", reader);
    chain.doIntercept(responseMsg);
  }
}

代码示例来源:origin: apache/cxf

public void handleMessage(Message message) throws Fault {
  Exchange ex = message.getExchange();
  Set<Endpoint> endpoints = CastUtils.cast((Set<?>)ex.get(MultipleEndpointObserver.ENDPOINTS));
  Endpoint ep = selectEndpoint(message, endpoints);
  if (ep == null) {
    return;
  }
  ex.put(Endpoint.class, ep);
  ex.put(Binding.class, ep.getBinding());
  ex.put(Service.class, ep.getService());
  InterceptorChain chain = message.getInterceptorChain();
  chain.add(ep.getInInterceptors());
  chain.add(ep.getBinding().getInInterceptors());
  chain.add(ep.getService().getInInterceptors());
  chain.setFaultObserver(ep.getOutFaultObserver());
}

代码示例来源:origin: apache/cxf

private Message createOutMessage(Message inMessage) {
    Endpoint e = inMessage.getExchange().getEndpoint();
    Message mout = e.getBinding().createMessage();
    mout.setExchange(inMessage.getExchange());
    mout.setInterceptorChain(
       OutgoingChainInterceptor.getOutInterceptorChain(inMessage.getExchange()));
    inMessage.getExchange().setOutMessage(mout);
    inMessage.getExchange().put("cxf.io.cacheinput", Boolean.FALSE);
    return mout;
  }
}

代码示例来源:origin: apache/cxf

protected void invokeInboundChain(Exchange ex, Endpoint ep) {
  Message m = getInBoundMessage(ex);
  Message inMsg = ep.getBinding().createMessage();
  MessageImpl.copyContent(m, inMsg);
  //Copy Response Context to Client inBound Message
  //TODO a Context Filter Strategy required.
  inMsg.putAll(m);
  inMsg.put(Message.REQUESTOR_ROLE, Boolean.TRUE);
  inMsg.put(Message.INBOUND_MESSAGE, Boolean.TRUE);
  inMsg.setExchange(ex);
  Exception exc = inMsg.getContent(Exception.class);
  if (exc != null) {
    ex.setInFaultMessage(inMsg);
    ColocInFaultObserver observer = new ColocInFaultObserver(bus);
    observer.onMessage(inMsg);
  } else {
    //Handle Response
    ex.setInMessage(inMsg);
    PhaseManager pm = bus.getExtension(PhaseManager.class);
    SortedSet<Phase> phases = new TreeSet<>(pm.getInPhases());
    ColocUtil.setPhases(phases, Phase.USER_LOGICAL, Phase.PRE_INVOKE);
    InterceptorChain chain = ColocUtil.getInInterceptorChain(ex, phases);
    inMsg.setInterceptorChain(chain);
    chain.doIntercept(inMsg);
  }
  ex.put(ClientImpl.FINISHED, Boolean.TRUE);
}

代码示例来源:origin: org.apache.cxf/cxf-rt-core

public void handleMessage(Message message) {
  if (isGET(message) && message.getContent(List.class) != null) {
    LOG.fine("StaxDataBindingInterceptor skipped in HTTP GET method");
    return;
  MessageContentsList parameters = new MessageContentsList();
  Exchange exchange = message.getExchange();
  BindingOperationInfo bop = exchange.get(BindingOperationInfo.class);
    Endpoint ep = exchange.get(Endpoint.class);
    bop = ep.getBinding().getBindingInfo().getOperations().iterator().next();
  message.getExchange().put(BindingOperationInfo.class, bop);

代码示例来源:origin: apache/cxf

public void handleMessage(Message message) {
  if (isGET(message) && message.getContent(List.class) != null) {
    LOG.fine("StaxDataBindingInterceptor skipped in HTTP GET method");
    return;
  MessageContentsList parameters = new MessageContentsList();
  Exchange exchange = message.getExchange();
  BindingOperationInfo bop = exchange.getBindingOperationInfo();
    Endpoint ep = exchange.getEndpoint();
    bop = ep.getBinding().getBindingInfo().getOperations().iterator().next();
  message.getExchange().put(BindingOperationInfo.class, bop);

代码示例来源:origin: apache/cxf

protected void initializeInterceptors(Exchange ex, PhaseInterceptorChain chain) {
  Endpoint e = ex.getEndpoint();
  Client c = ex.get(Client.class);
  chain.add(getBus().getOutFaultInterceptors());
  if (c != null) {
    chain.add(c.getOutFaultInterceptors());
  }
  chain.add(e.getService().getOutFaultInterceptors());
  chain.add(e.getOutFaultInterceptors());
  chain.add(e.getBinding().getOutFaultInterceptors());
  if (e.getService().getDataBinding() instanceof InterceptorProvider) {
    chain.add(((InterceptorProvider)e.getService().getDataBinding()).getOutFaultInterceptors());
  }
  addToChain(chain, ex.getInMessage());
  addToChain(chain, ex.getOutFaultMessage());
}
private void addToChain(PhaseInterceptorChain chain, Message m) {

代码示例来源:origin: apache/cxf

protected void initializeInterceptors(Exchange ex, PhaseInterceptorChain chain) {
  Endpoint e = ex.getEndpoint();
  Client c = ex.get(Client.class);
  InterceptorProvider ip = ex.get(InterceptorProvider.class);
  chain.add(getBus().getInFaultInterceptors());
  if (c != null) {
    chain.add(c.getInFaultInterceptors());
  } else if (ip != null) {
    chain.add(ip.getInFaultInterceptors());
  }
  chain.add(e.getService().getInFaultInterceptors());
  chain.add(e.getInFaultInterceptors());
  chain.add(e.getBinding().getInFaultInterceptors());
  if (e.getService().getDataBinding() instanceof InterceptorProvider) {
    chain.add(((InterceptorProvider)e.getService().getDataBinding()).getInFaultInterceptors());
  }
  addToChain(chain, ex.getInFaultMessage());
  addToChain(chain, ex.getOutMessage());
}
private void addToChain(PhaseInterceptorChain chain, Message m) {

代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws

message.getInterceptorChain().abort();
MessageObserver observer = message.getExchange().get(MessageObserver.class);
if (!message.getExchange().isOneWay()
  && observer != null) {
  Endpoint e = message.getExchange().getEndpoint();
  Message responseMsg = new MessageImpl();
  responseMsg.setExchange(message.getExchange());
  responseMsg = e.getBinding().createMessage(responseMsg);
    responseMsg.setContent(SOAPMessage.class, soapMessage);
    XMLStreamReader xmlReader = createXMLStreamReaderFromSOAPMessage(soapMessage);
    responseMsg.setContent(XMLStreamReader.class, xmlReader);
  responseMsg.put(InterceptorChain.STARTING_AT_INTERCEPTOR_ID,
Endpoint e = message.getExchange().getEndpoint();
if (!message.getExchange().isOneWay()) {
  Message responseMsg = new MessageImpl();
  responseMsg.setExchange(message.getExchange());
  responseMsg = e.getBinding().createMessage(responseMsg);
  message.getExchange().setOutMessage(responseMsg);
  SOAPMessage soapMessage = ((SOAPMessageContext)context).getMessage();

代码示例来源:origin: org.apache.cxf/cxf-api

public static InterceptorChain getOutInterceptorChain(Exchange ex) {
  Bus bus = ex.get(Bus.class);
  Binding binding = ex.get(Binding.class);
  PhaseManager pm = bus.getExtension(PhaseManager.class);
  PhaseInterceptorChain chain = new PhaseInterceptorChain(pm.getOutPhases());
  Endpoint ep = ex.get(Endpoint.class);
  List<Interceptor<? extends Message>> il = ep.getOutInterceptors();
  if (LOG.isLoggable(Level.FINE)) {
    LOG.fine("Interceptors contributed by endpoint: " + il);
  il = ep.getService().getOutInterceptors();
  if (LOG.isLoggable(Level.FINE)) {
    LOG.fine("Interceptors contributed by service: " + il);
  il = bus.getOutInterceptors();
  if (LOG.isLoggable(Level.FINE)) {
    LOG.fine("Interceptors contributed by bus: " + il);
    il = binding.getOutInterceptors();
    if (LOG.isLoggable(Level.FINE)) {
      LOG.fine("Interceptors contributed by binding: " + il);
  chain.setFaultObserver(ep.getOutFaultObserver());
  return chain;

代码示例来源:origin: apache/cxf

protected PhaseInterceptorChain setupInterceptorChain(Endpoint endpoint) {
  PhaseManager pm = bus.getExtension(PhaseManager.class);
  List<Interceptor<? extends Message>> i1 = bus.getOutInterceptors();
  if (LOG.isLoggable(Level.FINE)) {
    LOG.fine("Interceptors contributed by bus: " + i1);
  }
  List<Interceptor<? extends Message>> i2 = getOutInterceptors();
  if (LOG.isLoggable(Level.FINE)) {
    LOG.fine("Interceptors contributed by client: " + i2);
  }
  List<Interceptor<? extends Message>> i3 = endpoint.getOutInterceptors();
  if (LOG.isLoggable(Level.FINE)) {
    LOG.fine("Interceptors contributed by endpoint: " + i3);
  }
  List<Interceptor<? extends Message>> i4 = endpoint.getBinding().getOutInterceptors();
  if (LOG.isLoggable(Level.FINE)) {
    LOG.fine("Interceptors contributed by binding: " + i4);
  }
  List<Interceptor<? extends Message>> i5 = null;
  if (endpoint.getService().getDataBinding() instanceof InterceptorProvider) {
    i5 = ((InterceptorProvider)endpoint.getService().getDataBinding()).getOutInterceptors();
    if (LOG.isLoggable(Level.FINE)) {
      LOG.fine("Interceptors contributed by databinding: " + i5);
    }
  }
  if (i5 != null) {
    return outboundChainCache.get(pm.getOutPhases(), i1, i2, i3, i4, i5);
  }
  return outboundChainCache.get(pm.getOutPhases(), i1, i2, i3, i4);
}

代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws

private Message createResponseMessage() {
  if (exchange == null || exchange.isOneWay()) {
    return null;
    m = exchange.getInFaultMessage();
    if (m == null) {
      m = exchange.getInMessage();
      Endpoint ep = exchange.getEndpoint();
      m = new org.apache.cxf.message.MessageImpl();
      m.setExchange(exchange);
      m = ep.getBinding().createMessage(m);
      exchange.setInMessage(m);
      Endpoint ep = exchange.getEndpoint();
      m = new org.apache.cxf.message.MessageImpl();
      m.setExchange(exchange);
      m = ep.getBinding().createMessage(m);
      exchange.setOutMessage(m);

代码示例来源:origin: apache/cxf

private Message getOutMessage() {
  Message message = m.getExchange().getOutMessage();
  if (message == null) {
    Endpoint ep = m.getExchange().getEndpoint();
    message = new org.apache.cxf.message.MessageImpl();
    message.setExchange(m.getExchange());
    message = ep.getBinding().createMessage(message);
    m.getExchange().setOutMessage(message);
  }
  return message;
}

代码示例来源:origin: org.apache.geronimo.modules/geronimo-cxf-ejb

@Override
protected void init() {
  // configure handlers
  try {
    initHandlers();
  } catch (Exception e) {
    throw new WebServiceException("Error configuring handlers", e);
  }
  BeanContext beanContext =
    bus.getExtension(BeanContext.class);
  service.setInvoker(new EJBMethodInvoker(this, this.bus, beanContext));
  Endpoint endpoint = getEndpoint();
  /*
   * Remove interceptors that perform handler processing since
   * handler processing must happen within the EJB container.
   */
  removeHandlerInterceptors(bus.getInInterceptors());
  removeHandlerInterceptors(endpoint.getInInterceptors());
  removeHandlerInterceptors(endpoint.getBinding().getInInterceptors());
  removeHandlerInterceptors(endpoint.getService().getInInterceptors());
  // install SAAJ interceptor
  if (endpoint.getBinding() instanceof SoapBinding &&
    !this.implInfo.isWebServiceProvider()) {
    endpoint.getService().getInInterceptors().add(new SAAJInInterceptor());
  }
}

代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs

private Message createOutMessage(Message inMessage, Response r) {
    Endpoint e = inMessage.getExchange().get(Endpoint.class);
    Message mout = new MessageImpl();
    mout.setContent(List.class, new MessageContentsList(r));
    mout.setExchange(inMessage.getExchange());
    mout = e.getBinding().createMessage(mout);
    mout.setInterceptorChain(
       OutgoingChainInterceptor.getOutInterceptorChain(inMessage.getExchange()));
    inMessage.getExchange().setOutMessage(mout);
    if (r.getStatus() >= Response.Status.BAD_REQUEST.getStatusCode()) {
      inMessage.getExchange().put("cxf.io.cacheinput", Boolean.FALSE);
    }
    return mout;
  }
}

代码示例来源:origin: apache/cxf

private static InterceptorChain getRedeliveryInterceptorChain(Message m, String phase) {
  Exchange exchange = m.getExchange();
  Endpoint ep = exchange.getEndpoint();
  Bus bus = exchange.getBus();
  PhaseManager pm = bus.getExtension(PhaseManager.class);
  SortedSet<Phase> phases = new TreeSet<>(pm.getInPhases());
  for (Iterator<Phase> it = phases.iterator(); it.hasNext();) {
    Phase p = it.next();
    if (phase.equals(p.getName())) {
      break;
    }
    it.remove();
  }
  PhaseInterceptorChain chain = new PhaseInterceptorChain(phases);
  List<Interceptor<? extends Message>> il = ep.getInInterceptors();
  addInterceptors(chain, il);
  il = ep.getService().getInInterceptors();
  addInterceptors(chain, il);
  il = ep.getBinding().getInInterceptors();
  addInterceptors(chain, il);
  il = bus.getInInterceptors();
  addInterceptors(chain, il);
  if (ep.getService().getDataBinding() instanceof InterceptorProvider) {
    il = ((InterceptorProvider)ep.getService().getDataBinding()).getInInterceptors();
    addInterceptors(chain, il);
  }
  return chain;
}

相关文章