javax.xml.soap.SOAPHeader.getChildElements()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(106)

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

SOAPHeader.getChildElements介绍

暂无

代码示例

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

SOAPHeader head = SAAJUtils.getHeader(msg);
if (head != null) {
  Iterator<Node> it = CastUtils.cast(head.getChildElements());
  while (it != null && it.hasNext()) {
    Node nd = it.next();

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

SOAPHeader soapHeader = message.getSOAPHeader();
Iterator elements = soapHeader.getChildElements();

代码示例来源:origin: org.springframework.ws/org.springframework.ws

/** Returns all header elements. */
@Override
@SuppressWarnings("unchecked")
public Iterator<SOAPHeaderElement> examineAllHeaderElements(SOAPHeader header) {
  List<SOAPHeaderElement> result = new ArrayList<SOAPHeaderElement>();
  for (Iterator<?> iterator = header.getChildElements(); iterator.hasNext();) {
    Object o = iterator.next();
    if (o instanceof SOAPHeaderElement) {
      result.add((SOAPHeaderElement) o);
    }
  }
  return result.iterator();
}

代码示例来源:origin: org.switchyard/switchyard-security

private SOAPHeaderElement getSecurityHeader(SOAPEnvelope envelope) throws SOAPException {
  if (envelope != null) {
    SOAPHeader header = envelope.getHeader();
    if (header != null) {
      Iterator<?> iter = header.getChildElements(WSSE_QNAME);
      if (iter.hasNext()) {
        return (SOAPHeaderElement)iter.next();
      }
      iter = header.getChildElements(WSSE_2_QNAME);
      if (iter.hasNext()) {
        return (SOAPHeaderElement)iter.next();
      }
      iter = header.getChildElements(WSSE_11_QNAME);
      if (iter.hasNext()) {
        return (SOAPHeaderElement)iter.next();
      }
    }
  }
  return null;
}

代码示例来源:origin: se.skltp.mb/mb-intsvc

private String extractTargetOrg(SOAPMessage soapMessage) throws SOAPException {
  // rivta2.0 uses To, 2.1 uses LogicalAddress
  Iterator iter = soapMessage.getSOAPHeader().getChildElements(TO_QNAME);
  if (!iter.hasNext()) {
    iter = soapMessage.getSOAPHeader().getChildElements(LOGICAL_ADDRESS_QNAME);
  }
  if (!iter.hasNext()) {
    throw new RuntimeException("No address node found in header!");
  }
  return ((Node)iter.next()).getValue();
}

代码示例来源:origin: se.skltp.mb/mb-modules-intsvc

private String extractTargetOrg(SOAPMessage soapMessage) throws SOAPException {
  // rivta2.0 uses To, 2.1 uses LogicalAddress
  Iterator iter = soapMessage.getSOAPHeader().getChildElements(TO_QNAME);
  if ( !iter.hasNext() ) {
    iter = soapMessage.getSOAPHeader().getChildElements(LOGICAL_ADDRESS_QNAME);
  }
  if ( !iter.hasNext() ) {
    throw new RuntimeException("No address node found in header!");
  }
  return ((Node) iter.next()).getValue();
}

代码示例来源:origin: org.springframework.ws/spring-ws-core

@SuppressWarnings("unchecked")
@Override
public void removeHeaderElement(QName name) throws SoapHeaderException {
  Iterator<Node> iterator = getSaajHeader().getChildElements(name);
  if (iterator.hasNext()) {
    Node element = iterator.next();
    element.detachNode();
  }
}

代码示例来源:origin: net.bpelunit/framework

private String getMessageID(SOAPHeader header) {
  String messageID = "";
  for (Iterator<?> i = header.getChildElements(wsaQName(WSA_TAG_MESSAGE_ID)); i.hasNext();) {
    SOAPElement soapElement = (SOAPElement) i.next();
    messageID = soapElement.getTextContent();
  }
  return messageID;
}

代码示例来源:origin: spring-projects/spring-ws

@SuppressWarnings("unchecked")
@Override
public void removeHeaderElement(QName name) throws SoapHeaderException {
  Iterator<Node> iterator = getSaajHeader().getChildElements(name);
  if (iterator.hasNext()) {
    Node element = iterator.next();
    element.detachNode();
  }
}

代码示例来源:origin: org.apache.tuscany.sca/tuscany-base-runtime

/**
 * Handle a SOAP wsa:RelatesTo header - place the contents into the Tuscany message for use by any callback
 * @param header - the SOAP Headers
 * @param msg - the Tuscany Message
 */
private void handleRelatesToHeader( SOAPHeader header, Message msg ) {
  if( header == null ) return;
  Iterator<SOAPElement> it = header.getChildElements(QNAME_WSA_RELATESTO);
  SOAPElement relatesTo = it.hasNext() ? it.next() : null;        
  if (relatesTo != null) {
    String relatesToVal = relatesTo.getTextContent();
    msg.getHeaders().put(Constants.RELATES_TO, relatesToVal);
  } // end if
} // end method handleRelatesToHeader

代码示例来源:origin: apache/servicemix-bundles

@SuppressWarnings("unchecked")
@Override
public void removeHeaderElement(QName name) throws SoapHeaderException {
  Iterator<Node> iterator = getSaajHeader().getChildElements(name);
  if (iterator.hasNext()) {
    Node element = iterator.next();
    element.detachNode();
  }
}

代码示例来源:origin: org.apache.tuscany.sca/tuscany-base-runtime

/**
 * Handle a SOAP wsa:MessageID header - place the contents into the Tuscany message for use by any callback
 * @param header - the SOAP Headers
 * @param msg - the Tuscany Message
 */
private void handleMessageIDHeader( SOAPHeader header, Message msg ) {
  if( header == null ) return;
  Iterator<SOAPElement> it = header.getChildElements(QNAME_WSA_MESSAGEID);
  SOAPElement messageID = it.hasNext() ? it.next() : null;
  if (messageID != null) {
    String idValue = messageID.getTextContent();
    msg.getHeaders().put(Constants.MESSAGE_ID, idValue);
  } // end if
} // end method handleMessageID

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

SOAPHeader soapHeader = context.getMessage().getSOAPHeader();
   Object z;
   XMLUtil xmlUtil = new XMLUtil();
   for( Iterator<SOAPElement> it = soapHeader.getChildElements(new ObjectFactory().createServiceContext(null).getName()); it.hasNext(); ){
     SOAPElement sc = it.next();
     z = xmlUtil.unmarshall(sc, ServiceContextType.class);
   }

代码示例来源:origin: org.springframework.ws/spring-ws-core

@Override
@SuppressWarnings("unchecked")
public Iterator<SoapHeaderElement> examineHeaderElements(QName name) throws SoapHeaderException {
  Iterator<Node> iterator = getSaajHeader().getChildElements(name);
  return new SaajSoapHeaderElementIterator(iterator);
}

代码示例来源:origin: net.bpelunit/framework

private String getRelatesToID(SOAPHeader header)
    throws HeaderProcessingException {
  String relatesTo = null;
  for (Iterator<?> itRelatesTo = header.getChildElements(wsaQName(WSA_TAG_RELATES_TO)); itRelatesTo.hasNext();) {
    final SOAPElement soapE = (SOAPElement)itRelatesTo.next();
    relatesTo = soapE.getTextContent();
  }
  if (relatesTo == null) {
    throw new HeaderProcessingException("No RelatesTo header found in the incoming message");
  }
  return relatesTo;
}

代码示例来源:origin: spring-projects/spring-ws

@Override
@SuppressWarnings("unchecked")
public Iterator<SoapHeaderElement> examineHeaderElements(QName name) throws SoapHeaderException {
  Iterator<Node> iterator = getSaajHeader().getChildElements(name);
  return new SaajSoapHeaderElementIterator(iterator);
}

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

public boolean handleMessage(SOAPMessageContext context) { 
  try { 
    SOAPMessage message = context.getMessage(); 
    SOAPHeader header = message.getSOAPHeader();             
    if (header != null) { 
      Iterator i = header.getChildElements();
      //Navigate through header elements to get the username and password
    } 
  } catch (Exception e) { 
    //Handle exception 
  } 
  return true; 
}

代码示例来源:origin: apache/servicemix-bundles

@Override
@SuppressWarnings("unchecked")
public Iterator<SoapHeaderElement> examineHeaderElements(QName name) throws SoapHeaderException {
  Iterator<Node> iterator = getSaajHeader().getChildElements(name);
  return new SaajSoapHeaderElementIterator(iterator);
}

代码示例来源:origin: net.bpelunit/framework

private String getEndpointURL(SOAPHeader header, String wsaTagName)
    throws HeaderProcessingException {
  String replyTo = null;
  for (Iterator<?> i = header.getChildElements(wsaQName(wsaTagName)); i.hasNext();) {
    SOAPElement soapElement = (SOAPElement) i.next();
    for (Iterator<?> j = soapElement.getChildElements(wsaQName(WSA_TAG_ADDRESS)); j.hasNext();) {
      SOAPElement soapElement2 = (SOAPElement) j.next();
      replyTo = soapElement2.getTextContent();
    }
  }
  if (replyTo == null) {
    throw new HeaderProcessingException(wsaTagName + " address not found in incoming message.");
  }
  return replyTo;
}

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

public void handleMessage(SoapMessage mc) throws Fault {
  SOAPMessage saaj = mc.getContent(SOAPMessage.class);
  try {
    Iterator<?> secHeadersIterator =
      SAAJUtils.getHeader(saaj).getChildElements(SEC_HEADER);
    if (secHeadersIterator.hasNext()) {
      SOAPHeaderElement securityHeader =
        (SOAPHeaderElement)secHeadersIterator.next();
      modifySecurityHeader(securityHeader);
    }
    modifySOAPBody(SAAJUtils.getBody(saaj));
  } catch (SOAPException ex) {
    throw new Fault(ex);
  }
}

相关文章