Search in sources :

Example 1 with SAAJHeader

use of com.sun.xml.ws.message.saaj.SAAJHeader in project metro-jax-ws by eclipse-ee4j.

the class SAAJMessageHeaders method asList.

@Override
public List<Header> asList() {
    SOAPHeader soapHeader = ensureSOAPHeader();
    if (soapHeader == null) {
        return Collections.emptyList();
    }
    Iterator allHeaders = soapHeader.examineAllHeaderElements();
    List<Header> headers = new ArrayList<>();
    while (allHeaders.hasNext()) {
        SOAPHeaderElement nextHdr = (SOAPHeaderElement) allHeaders.next();
        headers.add(new SAAJHeader(nextHdr));
    }
    return headers;
}
Also used : SOAPHeaderElement(jakarta.xml.soap.SOAPHeaderElement) SAAJHeader(com.sun.xml.ws.message.saaj.SAAJHeader) Header(com.sun.xml.ws.api.message.Header) SOAPHeader(jakarta.xml.soap.SOAPHeader) SAAJHeader(com.sun.xml.ws.message.saaj.SAAJHeader) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) SOAPHeader(jakarta.xml.soap.SOAPHeader)

Example 2 with SAAJHeader

use of com.sun.xml.ws.message.saaj.SAAJHeader in project metro-jax-ws by eclipse-ee4j.

the class SAAJMessageHeaders method getNotUnderstoodHeaders.

@Override
public Set<QName> getNotUnderstoodHeaders(Set<String> roles, Set<QName> knownHeaders, WSBinding binding) {
    Set<QName> notUnderstoodHeaderNames = new HashSet<>();
    if (notUnderstoodCount == null) {
        return notUnderstoodHeaderNames;
    }
    for (Map.Entry<QName, Integer> header : notUnderstoodCount.entrySet()) {
        QName headerName = header.getKey();
        int count = header.getValue();
        if (count <= 0) {
            continue;
        }
        SOAPHeaderElement hdrElem = find(headerName);
        if (!hdrElem.getMustUnderstand()) {
            continue;
        }
        SAAJHeader hdr = new SAAJHeader(hdrElem);
        // mustUnderstand attribute is true - but there may be
        // additional criteria
        boolean understood = false;
        if (roles != null) {
            understood = !roles.contains(hdr.getRole(soapVersion));
        }
        if (understood) {
            continue;
        }
        // or is in knownheaders
        if (binding instanceof SOAPBindingImpl) {
            understood = ((SOAPBindingImpl) binding).understandsHeader(headerName);
            if (!understood) {
                if (knownHeaders != null && knownHeaders.contains(headerName)) {
                    understood = true;
                }
            }
        }
        if (!understood) {
            notUnderstoodHeaderNames.add(headerName);
        }
    }
    return notUnderstoodHeaderNames;
}
Also used : SOAPHeaderElement(jakarta.xml.soap.SOAPHeaderElement) QName(javax.xml.namespace.QName) SAAJHeader(com.sun.xml.ws.message.saaj.SAAJHeader) SOAPBindingImpl(com.sun.xml.ws.binding.SOAPBindingImpl) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Example 3 with SAAJHeader

use of com.sun.xml.ws.message.saaj.SAAJHeader in project metro-jax-ws by eclipse-ee4j.

the class SAAJMessageHeaders method remove.

@Override
public Header remove(String nsUri, String localName) {
    SOAPHeader soapHeader = ensureSOAPHeader();
    if (soapHeader == null) {
        return null;
    }
    SOAPHeaderElement headerElem = find(nsUri, localName);
    if (headerElem == null) {
        return null;
    }
    headerElem = (SOAPHeaderElement) soapHeader.removeChild(headerElem);
    // it might have been a nonSAAJHeader - remove from that map
    removeNonSAAJHeader(headerElem);
    // remove it from understoodHeaders and notUnderstoodHeaders if present
    QName hdrName = (nsUri == null) ? new QName(localName) : new QName(nsUri, localName);
    if (understoodHeaders != null) {
        understoodHeaders.remove(hdrName);
    }
    removeNotUnderstood(hdrName);
    return new SAAJHeader(headerElem);
}
Also used : SOAPHeaderElement(jakarta.xml.soap.SOAPHeaderElement) QName(javax.xml.namespace.QName) SAAJHeader(com.sun.xml.ws.message.saaj.SAAJHeader) SOAPHeader(jakarta.xml.soap.SOAPHeader)

Example 4 with SAAJHeader

use of com.sun.xml.ws.message.saaj.SAAJHeader in project metro-jax-ws by eclipse-ee4j.

the class SAAJMessageHeaders method getHeaders.

@Override
public Iterator<Header> getHeaders(final String nsUri, final String localName, final boolean markAsUnderstood) {
    SOAPHeader soapHeader = ensureSOAPHeader();
    if (soapHeader == null) {
        return null;
    }
    Iterator allHeaders = soapHeader.examineAllHeaderElements();
    if (markAsUnderstood) {
        // mark all the matchingheaders as understood up front
        // make an iterator while we're doing that
        List<Header> headers = new ArrayList<>();
        while (allHeaders.hasNext()) {
            SOAPHeaderElement nextHdr = (SOAPHeaderElement) allHeaders.next();
            if (nextHdr != null && nextHdr.getNamespaceURI().equals(nsUri)) {
                if (localName == null || nextHdr.getLocalName().equals(localName)) {
                    understood(nextHdr.getNamespaceURI(), nextHdr.getLocalName());
                    headers.add(new SAAJHeader(nextHdr));
                }
            }
        }
        return headers.iterator();
    }
    // than traverse the entire list of headers now
    return new HeaderReadIterator(allHeaders, nsUri, localName);
}
Also used : SOAPHeaderElement(jakarta.xml.soap.SOAPHeaderElement) SAAJHeader(com.sun.xml.ws.message.saaj.SAAJHeader) Header(com.sun.xml.ws.api.message.Header) SOAPHeader(jakarta.xml.soap.SOAPHeader) SAAJHeader(com.sun.xml.ws.message.saaj.SAAJHeader) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) SOAPHeader(jakarta.xml.soap.SOAPHeader)

Aggregations

SAAJHeader (com.sun.xml.ws.message.saaj.SAAJHeader)4 SOAPHeaderElement (jakarta.xml.soap.SOAPHeaderElement)4 SOAPHeader (jakarta.xml.soap.SOAPHeader)3 Header (com.sun.xml.ws.api.message.Header)2 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 QName (javax.xml.namespace.QName)2 SOAPBindingImpl (com.sun.xml.ws.binding.SOAPBindingImpl)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1