public static void validateSOAPHeader(SOAPHeader soapHeader){
  Set<QName> fields=new HashSet<>();
  Iterator<?> it=soapHeader.getChildElements();
  while (it.hasNext()) {
    Object next=it.next();
    if (next instanceof SOAPElement) {
      SOAPElement soapElement=(SOAPElement)next;
      if (!fields.add(soapElement.getElementQName())) {
        throw new CodedException(X_DUPLICATE_HEADER_FIELD,"SOAP header contains duplicate field '%s'",soapElement.getElementQName());
      }
    }
  }
}

public static void validateSOAPHeader ( SOAPHeader soapHeader ) { Set < QName > fields = new HashSet < > ( ) ; Iterator < ? > it = soapHeader . getChildElements ( ) ; while ( it . hasNext ( ) ) { Object next = it . next ( ) ; if ( next instanceof SOAPElement ) { SOAPElement soapElement = ( SOAPElement ) next ; if ( ! fields . add ( soapElement . getElementQName ( ) ) ) { throw new CodedException ( X_DUPLICATE_HEADER_FIELD , "SOAP header contains duplicate field '%s'" , soapElement . getElementQName ( ) ) ; } } } }
checks soap header for duplicate fields .
