org.apache.cxf.headers.Header类的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(13.4k)|赞(0)|评价(0)|浏览(158)

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

Header介绍

暂无

代码示例

代码示例来源:origin: se.skltp.agp/agp-test-common

@Override
  public void handleMessage(SoapMessage message) throws Fault {
    List<Header> headers = message.getHeaders();
    for (Header header : headers) {
      if ("ProcessingStatus".equals(header.getName().getLocalPart()) && 
        "urn:riv:interoperability:headers:1".equals(header.getName().getNamespaceURI())) {

        try {
          ProcessingStatusType ps = (ProcessingStatusType)ju.unmarshal(header.getObject());
          lastFoundProcessingStatus = ps;
        } catch (Throwable ex) {
        }
      }
    }
  }
}

代码示例来源:origin: opensourceBIM/BIMserver

@Override
public void newToken(String token) {
  if (useSoapHeaderSessions) {
    for (PublicInterface p : getServiceInterfaces().values()) {
      List<Header> headers = new ArrayList<Header>();
      try {
        Token tokenObject = new Token(token);
        Header sessionHeader = new Header(new QName("uri:org.bimserver.shared", "token"), tokenObject, new JAXBDataBinding(Token.class));
        headers.add(sessionHeader);
      } catch (JAXBException e) {
        LOGGER.error("", e);
      }
      ((BindingProvider) p).getRequestContext().put(Header.HEADER_LIST, headers);
    }
  }
}

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

protected void updateHeader(Exchange exchange, MessageContext ctx) {
  if (ctx.containsKey(Header.HEADER_LIST)
      && ctx.get(Header.HEADER_LIST) instanceof List<?>) {
    List<?> list = (List<?>) ctx.get(Header.HEADER_LIST);
    if (list != null && !list.isEmpty()) {
      SoapMessage sm = (SoapMessage) createResponseMessage(exchange);
      if (sm != null) {
        Iterator<?> iter = list.iterator();
        while (iter.hasNext()) {
          Header header = (Header) iter.next();
          if (header.getDirection() != Header.Direction.DIRECTION_IN
            && !header.getName().getNamespaceURI().
              equals("http://docs.oasis-open.org/wss/2004/01/"
                  + "oasis-200401-wss-wssecurity-secext-1.0.xsd")
                && !header.getName().getNamespaceURI().
                  equals("http://docs.oasis-open.org/"
                     + "wss/oasis-wss-wssecurity-secext-1.1.xsd")) {
            //don't copy over security header, out interceptor chain will take care of it.
            sm.getHeaders().add(header);
          }
        }
      }
    }
  }
}

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

if (partWrapper != null) {
  if (!JbiConstants.WSDL11_WRAPPER_NAMESPACE.equals(element
      .getNamespaceURI())
      || !JbiConstants.WSDL11_WRAPPER_PART_LOCALNAME
          .equals(partWrapper.getLocalName())) {
    throw new Fault(new Exception(
        "Unexpected part wrapper element '"
            + "}part'"));
  NodeList nodes = partWrapper.getChildNodes();
  partsContent.add(nodes);
List<Header> headerList = message.getHeaders();
List<SoapHeaderInfo> headers = msg.getExtensors(SoapHeaderInfo.class);
for (SoapHeaderInfo header : headers) {
  if (header.getPart().getConcreteName().getNamespaceURI().equals(
      nl.item(0).getNamespaceURI())
      && header.getPart().getConcreteName().getLocalPart()
          .equals(nl.item(0).getLocalName())) {
    headerList.add(new Header(header.getPart().getConcreteName(),
        nl.item(0)));
    partsContent.remove(0);

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

if (o instanceof Element || o instanceof JAXBElement) {
  if (header == null) {
    header = getHeaderFactory().getHeader(msg.getVersion());
    Node importedNode = header.getOwnerDocument().importNode(e, true);
    header.appendChild(importedNode);
  } else {
    jaxbEl = (JAXBElement<?>) o;
  Element lastAdded = (Element)header.getLastChild();
  header.removeChild(lastAdded);
  addIsReferenceParameterMarkerAttribute(lastAdded, maps.getNamespaceURI());
  Header holder = new Header(new QName(lastAdded.getNamespaceURI(),
                     lastAdded.getLocalName()),
                     lastAdded);
  msg.getHeaders().add(holder);
} else {
  LOG.log(Level.WARNING, "IGNORE_NON_ELEMENT_REF_PARAM_MSG", o);

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

protected Header findSecurityHeader(SoapMessage message, boolean create) {
  for (Header h : message.getHeaders()) {
    QName n = h.getName();
    if ("Security".equals(n.getLocalPart())
      && (n.getNamespaceURI().equals(WSS4JConstants.WSSE_NS)
        || n.getNamespaceURI().equals(WSS4JConstants.WSSE11_NS))) {
      return h;
    }
  }
  if (!create) {
    return null;
  }
  Document doc = DOMUtils.getEmptyDocument();
  Element el = doc.createElementNS(WSS4JConstants.WSSE_NS, "wsse:Security");
  el.setAttributeNS(WSS4JConstants.XMLNS_NS, "xmlns:wsse", WSS4JConstants.WSSE_NS);
  SoapHeader sh = new SoapHeader(new QName(WSS4JConstants.WSSE_NS, "Security"), el);
  sh.setMustUnderstand(true);
  message.getHeaders().add(sh);
  return sh;
}

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

private void addPartialResponseHeader(SoapMessage message) {
  try {
    // add piggybacked wsa:From header to partial response
    List<Header> header = message.getHeaders();
    Document doc = DOMUtils.getEmptyDocument();
    SoapVersion ver = message.getVersion();
    Element hdr = doc.createElementNS(ver.getHeader().getNamespaceURI(),
      ver.getHeader().getLocalPart());
    hdr.setPrefix(ver.getHeader().getPrefix());
    marshallFrom("urn:piggyback_responder", hdr, getMarshaller());
    Element elem = DOMUtils.getFirstElement(hdr);
    while (elem != null) {
      Header holder = new Header(
          new QName(elem.getNamespaceURI(), elem.getLocalName()),
          elem, null);
      header.add(holder);
      elem = DOMUtils.getNextElement(elem);
    }
  } catch (Exception e) {
    verificationCache.put("SOAP header addition failed: " + e);
    e.printStackTrace();
  }
}

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

Iterator<Header> iter = headers.iterator();
while (iter.hasNext()) {
  Object obj = iter.next().getObject();
  if (obj instanceof Element) {
    Element hdr = (Element) obj;
    if (namespaceURI.equals(hdr.getNamespaceURI())) {
      if (namespaceURI.endsWith("addressing")) {
        currentNamespaceURI = namespaceURI;
        wsaHeaders.add(hdr.getLocalName());
      } else if (MAPTestBase.CUSTOMER_NAME.getNamespaceURI().equals(namespaceURI)) {
        String headerText = hdr.getTextContent();
        if (MAPTestBase.CUSTOMER_KEY.equals(headerText)) {
          wsaHeaders.add(hdr.getLocalName());
    if (namespaceURI.equals(el.getName().getNamespaceURI())) {
      if (namespaceURI.endsWith("addressing")) {
        currentNamespaceURI = namespaceURI;
        wsaHeaders.add(el.getName().getLocalPart());
      } else if (MAPTestBase.CUSTOMER_NAME.getNamespaceURI().equals(namespaceURI)) {
        String headerText = (String)el.getValue();

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

if (message.hasAdditionalEnvNs()) {
             soapVersion.getHeader().getLocalPart(),
    if (xtw instanceof W3CDOMStreamWriter) {
      Element nd = ((W3CDOMStreamWriter)xtw).getCurrentNode();
      if (header.getObject() instanceof Element
        && nd.isSameNode(((Element)header.getObject()).getParentNode())) {
        continue;
      writer = new SOAPHeaderWriter(xtw, soapHeader, soapVersion, soapPrefix);
    DataBinding b = header.getDataBinding();
    if (b == null) {
      HeaderProcessor hp = bus.getExtension(HeaderManager.class)
          .getHeaderProcessor(header.getName().getNamespaceURI());
      if (hp != null) {
        b = hp.getDataBinding();
      MessagePartInfo part = new MessagePartInfo(header.getName(), null);
      part.setConcreteName(header.getName());
      b.createWriter(XMLStreamWriter.class)
        .write(header.getObject(), part, writer);
    } else {
      Element node = (Element)header.getObject();
      StaxUtils.copy(node, writer);

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

protected void addToken(SoapMessage message) {
  UsernameToken tok = assertTokens(message);
  Header h = findSecurityHeader(message, true);
  Element el = (Element)h.getObject();
  Document doc = el.getOwnerDocument();
  WSSecUsernameToken utBuilder =
    addUsernameToken(message, doc, tok);
  if (utBuilder == null) {
    AssertionInfoMap aim = message.get(AssertionInfoMap.class);
    Collection<AssertionInfo> ais =
      PolicyUtils.getAllAssertionsByLocalname(aim, SPConstants.USERNAME_TOKEN);
    for (AssertionInfo ai : ais) {
      if (ai.isAsserted()) {
        ai.setAsserted(false);
      }
    }
    return;
  }
  utBuilder.prepare();
  el.appendChild(utBuilder.getUsernameTokenElement());
}

代码示例来源:origin: org.openehealth.ipf.commons/ipf-commons-ihe-ws

for (Header header : message.getHeaders()) {
    if ("RelatesTo".equals(header.getName().getLocalPart())
        && VersionTransformer.isSupported(header.getName().getNamespaceURI()))
      messageId = ((Element) header.getObject()).getTextContent();
      break;
Exchange exchange = message.getExchange();
if ((message == exchange.getInFaultMessage())
    || (message == exchange.getOutFaultMessage())

代码示例来源:origin: org.talend.esb.job/org.talend.esb.job.controller

@SuppressWarnings("unchecked")
private List<Header> listSoapHeaders(Object soapHeadersObject) throws TransformerFactoryConfigurationError {
  if (null != soapHeadersObject) {
    if (soapHeadersObject instanceof org.dom4j.Document) {
      List<Header> soapHeaders = new ArrayList<Header>();
      try {
        DOMResult result = new DOMResult();
        TransformerFactory.newInstance().newTransformer()
            .transform(new org.dom4j.io.DocumentSource((org.dom4j.Document) soapHeadersObject), result);
        for (Node node = ((Document) result.getNode()).getDocumentElement()
            .getFirstChild(); node != null; node = node.getNextSibling()) {
          if (Node.ELEMENT_NODE == node.getNodeType()) {
            soapHeaders.add(new Header(new QName(node.getNamespaceURI(), node.getLocalName()), node));
          }
        }
      } catch (Exception e) {
        LOG.log(Level.SEVERE, "Uncaught exception during SOAP headers transformation: ", e);
      }
    } else if (soapHeadersObject instanceof List) {
      return (List<Header>) soapHeadersObject;
    }
  }
  return null;
}

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

return;
Element el = (Element)h.getObject();
Element child = DOMUtils.getFirstElement(el);
while (child != null) {
  if (WSS4JConstants.BINARY_TOKEN_LN.equals(child.getLocalName())
    && WSS4JConstants.WSSE_NS.equals(child.getNamespaceURI())) {
    try {
      List<WSSecurityEngineResult> bstResults = processToken(child, message);
      if (bstResults != null) {
        List<WSHandlerResult> results = CastUtils.cast((List<?>)message
            .get(WSHandlerConstants.RECV_RESULTS));
        if (results == null) {
          results = new ArrayList<>();
          message.put(WSHandlerConstants.RECV_RESULTS, results);
          (Principal)bstResults.get(0).get(WSSecurityEngineResult.TAG_PRINCIPAL);
        SecurityContext sc = message.get(SecurityContext.class);
        if (sc == null || sc.getUserPrincipal() == null) {
          message.put(SecurityContext.class, new DefaultSecurityContext(principal, null));

代码示例来源:origin: org.mule.modules/mule-module-cxf

if (!message.hasHeaders())
Header mule_header = message.getHeader(MULE_HEADER_Q);
if (mule_header == null)
Object obj = mule_header.getObject();
if (!(obj instanceof Element))
NodeList mule_headers = header_element.getChildNodes();
int idx = 0;
Node child;
  if (child_el.getNamespaceURI() == null || !child_el.getNamespaceURI().equals(MULE_NS_URI))
  if (SUPPORTED_HEADERS.contains(child_el.getLocalName()))
    message.put(child_el.getLocalName(), collectTextFrom(child_el));

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

private static Header findHeader(List<Header> headerElement,
    MessagePartInfo mpi) {
  Header param = null;
  if (headerElement != null) {
    QName name = mpi.getConcreteName();
    for (Header header : headerElement) {
      if (mpi.isElement()) {
        if (header.getName().getNamespaceURI() != null
          && header.getName().getNamespaceURI().equals(
              name.getNamespaceURI())
          && header.getName().getLocalPart() != null
          && header.getName().getLocalPart().equals(
              name.getLocalPart())) {
          param = header;
        }
      } else {
        if (header.getName().getLocalPart() != null
            && header.getName().getLocalPart().equals(
              name.getLocalPart())) {
          param = header;
        }
      }
    }
  }
  return param;
}

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

/**
 * Convert SoapMessage headers to NormalizedMessage headers
 */
private void toNMSHeaders(NormalizedMessage normalizedMessage,
    Message soapMessage) {
  SoapMessage message = null;
  if (!(soapMessage instanceof SoapMessage)) {
    return;
  } else {
    message = (SoapMessage) soapMessage;
  }
  Map<String, Object> headers = new HashMap<String, Object>();
  QName excludeName = new QName(
      "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd",
      "Security");
  for (Header header : message.getHeaders()) {
    if (!header.getName().equals(excludeName)) {
      // We must exclude this security header since in Sun's SAAJ impl, the ElementImpl
      // has a field which doesn't implement Serializable interface, which will cause
      //java.io.NotSerializableException when we try to serialize the JBI message.
      // And this security header isn't necessary inside jbi container since we have already
      // delegate the AA to JAAS at this stage.
      // SM-1696 track this issue
      headers.put(QNameUtil.toString(header.getName()), header
        .getObject());
    }
  }
  normalizedMessage.setProperty(CxfJbiConstants.PROTOCOL_HEADERS, headers);
}

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

protected void addToken(SoapMessage message) {
  SecurityToken securityToken = getSecurityToken(message);
  if (securityToken == null || securityToken.getToken() == null) {
    // No SecurityToken so just return
    return;
  }
  assertTokens(message);
  Header h = findSecurityHeader(message, true);
  Element el = (Element)h.getObject();
  el.appendChild(el.getOwnerDocument().importNode(securityToken.getToken(), true));
}

代码示例来源:origin: stackoverflow.com

List<Header> headers = getHeaders();
   for(Iterator<Header> i = headers.iterator(); i.hasNext();) { 
     Header h = i.next(); 
     Element n = (Element)h.getObject(); 
     System.out.println("header name="+n.getLocalName()); 
     System.out.println("header content="+n.getTextContent()); 
 }

代码示例来源:origin: org.kuali.student.core/ks-standard-sec

super.doResults(msg, actor, soapHeader, soapBody, wsResult);
QName wsseQN = new QName("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "Security");
if (msg.hasHeader(wsseQN)) {
  Header wsseHeader = msg.getHeader(wsseQN);
    Node domSecurityHeader = (Node) wsseHeader.getObject();
    NodeList nodeList = domSecurityHeader.getChildNodes();
    Node childNode = null;
  Node env = msg.getContent(Node.class);
  DOMSource domSource = new DOMSource(env);
  StringWriter writer = new StringWriter();

代码示例来源:origin: opensourceBIM/BIMserver

if (inMessage instanceof SoapMessage) {
  SoapMessage soapMessage = (SoapMessage) inMessage;
  Header header = soapMessage.getHeader(new QName("uri:org.bimserver.shared", "token"));
  String token = null;
  if (header != null) {
    token = ((Token)(header.getObject())).getToken();

相关文章