org.apache.cxf.headers.Header.<init>()方法的使用及代码示例

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

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

Header.<init>介绍

暂无

代码示例

代码示例来源: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.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: Talend/tesb-rt-se

@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: tracee/tracee

private void addSoapHeader(Map<String, String> filteredParams, SoapMessage soapMessage) {
  try {
    final Header tpicHeader = new Header(TraceeConstants.SOAP_HEADER_QNAME, TpicMap.wrap(filteredParams),
      new JAXBDataBinding(TpicMap.class));
    soapMessage.getHeaders().add(tpicHeader);
  } catch (JAXBException e) {
    LOGGER.warn("Error occured during TracEE soap header creation: {}", e.getMessage());
    LOGGER.debug("Detailed exception", e);
  }
}

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

/**
 * Builds an element containing a WS-RM Fault. This adds the appropriate WS-RM namespace declaration to
 * the element, and then adds the Fault as a child element.
 *
 * @param sf
 * @param qname constructed element name
 * @return element
 */
public Header buildHeaderFault(SequenceFault sf) throws JAXBException {
  Object o = buildHeaderFaultObject(sf);
  
  return new Header(new QName(getConstants().getWSRMNamespace(),
                RMConstants.SEQUENCE_FAULT_NAME),
           o, getDataBinding());
}

代码示例来源:origin: salesforce-marketingcloud/FuelSDK-Java

/** 
* Class constructor, Initializes a new instance of the class.
 * @param client        The ETClient object
 * @param endpoint      The endpoint URL
 * @param accessToken   The access token
 * @throws com.exacttarget.fuelsdk.ETSdkException
*/
public ETSoapConnection(ETClient client, String endpoint, String accessToken)
  throws ETSdkException
{
  this(client, endpoint);
  try {
    List<Header> headers = new ArrayList<Header>();
    accessTokenElement =
        soapFactory.createElement(new QName(null, "fueloauth"));
    if (accessToken != null) {
      setAccessToken(accessToken);
    }
    headers.add(new Header(new QName(null, "fueloauth"), accessTokenElement));
    
    soapClient.getRequestContext().put(Header.HEADER_LIST, headers);
  } catch (SOAPException ex) {
    throw new ETSdkException("could not initialize SOAP proxy", ex);
  }
}

代码示例来源:origin: Talend/tesb-rt-se

/**
 * Write flow id to message.
 *
 * @param message the message
 * @param flowId the flow id
 */
public static void writeFlowId(Message message, String flowId) {
  if (!(message instanceof SoapMessage)) {
    return;
  }
  SoapMessage soapMessage = (SoapMessage)message;
  Header hdFlowId = soapMessage.getHeader(FLOW_ID_QNAME);
  if (hdFlowId != null) {
    LOG.warning("FlowId already existing in soap header, need not to write FlowId header.");
    return;
  }
  try {
    soapMessage.getHeaders().add(
        new Header(FLOW_ID_QNAME, flowId, new JAXBDataBinding(String.class)));
    if (LOG.isLoggable(Level.FINE)) {
      LOG.fine("Stored flowId '" + flowId + "' in soap header: " + FLOW_ID_QNAME);
    }
  } catch (JAXBException e) {
    LOG.log(Level.SEVERE, "Couldn't create flowId header.", e);
  }
}

代码示例来源:origin: org.talend.esb/sam-agent

/**
 * Write flow id to message.
 *
 * @param message the message
 * @param flowId the flow id
 */
public static void writeFlowId(Message message, String flowId) {
  if (!(message instanceof SoapMessage)) {
    return;
  }
  SoapMessage soapMessage = (SoapMessage)message;
  Header hdFlowId = soapMessage.getHeader(FLOW_ID_QNAME);
  if (hdFlowId != null) {
    LOG.warning("FlowId already existing in soap header, need not to write FlowId header.");
    return;
  }
  try {
    soapMessage.getHeaders().add(
        new Header(FLOW_ID_QNAME, flowId, new JAXBDataBinding(String.class)));
    if (LOG.isLoggable(Level.FINE)) {
      LOG.fine("Stored flowId '" + flowId + "' in soap header: " + FLOW_ID_QNAME);
    }
  } catch (JAXBException e) {
    LOG.log(Level.SEVERE, "Couldn't create flowId header.", e);
  }
}

代码示例来源:origin: Talend/tesb-rt-se

private static Header createHeader(QName headerName, String value) throws Fault {
  try {
    return new Header(headerName, value, new JAXBDataBinding(String.class));
  } catch (JAXBException e) {
    throw new Fault(e);
  }
}

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

Header holder = new Header(new QName(lastAdded.getNamespaceURI(),
                   lastAdded.getLocalName()),
                   lastAdded);

代码示例来源:origin: Talend/components

public void setBodyFieldsOnly(boolean bodyFieldsOnly) {
  this.bodyFieldsOnly = bodyFieldsOnly;
  searchPreferences.setBodyFieldsOnly(bodyFieldsOnly);
  Object searchPreferencesObject = createNativeSearchPreferences(searchPreferences);
  try {
    Header searchPreferencesHeader = new Header(
        new QName(getPlatformMessageNamespaceUri(), "searchPreferences"),
        searchPreferencesObject, new JAXBDataBinding(searchPreferencesObject.getClass()));
    setHeader(port, searchPreferencesHeader);
  } catch (JAXBException e) {
    throw new NetSuiteException(new NetSuiteErrorCode(NetSuiteErrorCode.INTERNAL_ERROR),
        NetSuiteRuntimeI18n.MESSAGES.getMessage("error.binding"), e);
  }
}

代码示例来源:origin: Talend/components

/**
 * Set preferences for given port.
 *
 * @param port port which to set preferences for
 * @param nsPreferences general preferences
 * @param nsSearchPreferences search preferences
 * @throws NetSuiteException if an error occurs during performing of operation
 */
protected void setPreferences(PortT port,
    NsPreferences nsPreferences, NsSearchPreferences nsSearchPreferences) throws NetSuiteException {
  Object searchPreferences = createNativeSearchPreferences(nsSearchPreferences);
  Object preferences = createNativePreferences(nsPreferences);
  try {
    Header searchPreferencesHeader = new Header(
        new QName(getPlatformMessageNamespaceUri(), "searchPreferences"),
        searchPreferences, new JAXBDataBinding(searchPreferences.getClass()));
    Header preferencesHeader = new Header(
        new QName(getPlatformMessageNamespaceUri(), "preferences"),
        preferences, new JAXBDataBinding(preferences.getClass()));
    setHeader(port, preferencesHeader);
    setHeader(port, searchPreferencesHeader);
  } catch (JAXBException e) {
    throw new NetSuiteException(new NetSuiteErrorCode(NetSuiteErrorCode.INTERNAL_ERROR),
        NetSuiteRuntimeI18n.MESSAGES.getMessage("error.binding"), e);
  }
}

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

public BareDocumentResponse testDocLitFault(String in) throws BadRecordLitFault {
  //System.out.println("Executing testDocLitFault sayHi\n");
  List<Header> headers = new ArrayList<>();
  Header header = null;
  try {
    header = new Header(new QName("http://test", "test"),
              new String("test"), new JAXBDataBinding(String.class));
  } catch (JAXBException e) {
    e.printStackTrace();
  }
  headers.add(header);
  context.getMessageContext().put(Header.HEADER_LIST, headers);
  throw new BadRecordLitFault("int fault", 5);
}

代码示例来源:origin: Talend/components

/**
 * Set log-in specific SOAP headers for given port.
 *
 * @param port port
 * @throws NetSuiteException if an error occurs during performing of operation
 */
protected void setLoginHeaders(PortT port) throws NetSuiteException {
  if (!StringUtils.isEmpty(credentials.getApplicationId())) {
    Object applicationInfo = createNativeApplicationInfo(credentials);
    try {
      if (applicationInfo != null) {
        Header appInfoHeader = new Header(
            new QName(getPlatformMessageNamespaceUri(), "applicationInfo"),
            applicationInfo, new JAXBDataBinding(applicationInfo.getClass()));
        setHeader(port, appInfoHeader);
      }
    } catch (JAXBException e) {
      throw new NetSuiteException(new NetSuiteErrorCode(NetSuiteErrorCode.INTERNAL_ERROR),
          NetSuiteRuntimeI18n.MESSAGES.getMessage("error.binding"), e);
    }
  }
}

代码示例来源:origin: Talend/components

/**
 * Remove log-in specific SOAP headers for given port.
 *
 * @param port port
 * @throws NetSuiteException if an error occurs during performing of operation
 */
protected void updateLoginHeaders(PortT port) throws NetSuiteException {
  if (!isUseRequestLevelCredentials()) {
    removeHeader(port, new QName(getPlatformMessageNamespaceUri(), "applicationInfo"));
  } else {
    Object passport = createNativePassport(credentials);
    try {
      if (passport != null) {
        Header passportHeader = new Header(
            new QName(getPlatformMessageNamespaceUri(), "passport"),
            passport, new JAXBDataBinding(passport.getClass()));
        setHeader(port, passportHeader);
      }
    } catch (JAXBException e) {
      throw new NetSuiteException(new NetSuiteErrorCode(NetSuiteErrorCode.INTERNAL_ERROR),
          NetSuiteRuntimeI18n.MESSAGES.getMessage("error.binding"), e);
    }
  }
}

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

new QName(OOBHeaderTest.TEST_HDR_NS, OOBHeaderTest.TEST_HDR_RESPONSE_ELEM),
    OutofBandHeader.class, null, ob);
Header hdr = new Header(
    new QName(OOBHeaderTest.TEST_HDR_NS, OOBHeaderTest.TEST_HDR_RESPONSE_ELEM),
    job,

代码示例来源: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

@org.junit.Test
public void testKeyIdentifier2() throws Exception {
  if (test.isStreaming()) {
    return;
  }
  SpringBusFactory bf = new SpringBusFactory();
  URL busFile = X509TokenTest.class.getResource("client.xml");
  Bus bus = bf.createBus(busFile.toString());
  BusFactory.setDefaultBus(bus);
  BusFactory.setThreadDefaultBus(bus);
  URL wsdl = X509TokenTest.class.getResource("DoubleItOperations.wsdl");
  Service service = Service.create(wsdl, SERVICE_QNAME);
  QName portQName = new QName(NAMESPACE, "DoubleItKeyIdentifierPort2");
  DoubleItPortType2 x509Port =
      service.getPort(portQName, DoubleItPortType2.class);
  updateAddressPort(x509Port, PORT);
  List<Header> headers = new ArrayList<>();
  Header dummyHeader = new Header(new QName("uri:org.apache.cxf", "dummy"), "dummy-header",
                  new JAXBDataBinding(String.class));
  headers.add(dummyHeader);
  ((BindingProvider)x509Port).getRequestContext().put(Header.HEADER_LIST, headers);
  int response = x509Port.doubleIt(25);
  assertEquals(50, response);
  int response2 = x509Port.doubleIt2(15);
  assertEquals(30, response2);
  ((java.io.Closeable)x509Port).close();
  bus.shutdown(true);
}

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

s.setMessageNumber(msgId.getAndIncrement());
JAXBElement<AppSequenceType> seq = new ObjectFactory().createAppSequence(s);
Header h = new Header(seq.getName(),
           seq,
           new JAXBDataBinding(getJAXBContext()));

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

s.setMessageNumber(msgId.getAndIncrement());
JAXBElement<AppSequenceType> seq = new ObjectFactory().createAppSequence(s);
Header h = new Header(seq.getName(),
           seq,
           new JAXBDataBinding(getJAXBContext()));

相关文章