Class HeaderList
- All Implemented Interfaces:
MessageHeaders,Serializable,Cloneable,Iterable<Header>,Collection<Header>,List<Header>,RandomAccess
Headers on a Message.
This list can be modified to add headers
from outside a Message, this is necessary
since intermediate processing layers often need to
put additional headers.
Following the SOAP convention, the order among headers
are not significant. However, Codecs are
expected to preserve the order of headers in the input
message as much as possible.
MustUnderstand Processing
To perform SOAP mustUnderstang processing correctly, we need to keep
track of headers that are understood and headers that are not.
This is a collaborative process among Pipes, thus it's something
a Pipe author needs to keep in mind.
Specifically, when a Pipe sees a header and processes it
(that is, if it did enough computing with the header to claim that
the header is understood), then it should mark the corresponding
header as "understood". For example, when a pipe that handles JAX-WSA
examins the <wsa:To> header, it can claim that it understood the header.
But for example, if a pipe that does the signature verification checks
<wsa:To> for a signature, that would not be considered as "understood".
There are two ways to mark a header as understood:
- Use one of the
getXXXmethods that take a booleanmarkAsUnderstoodparameter. Most often, aPipeknows it's going to understand a header as long as it's present, so this is the easiest and thus the preferred way. For example, if JAX-WSA looks for <wsa:To>, then it can setmarkAsUnderstandto true, to do the obtaining of a header and marking at the same time. - Call
understood(int). If under a rare circumstance, a pipe cannot determine whether it can understand it or not when you are fetching a header, then you can use this method afterward to mark it as understood.
Intuitively speaking, at the end of the day, if a header is not
understood but Header.isIgnorable(SOAPVersion, java.util.Set) is false, a bad thing
will happen. The actual implementation of the checking is more complicated,
for that see ClientMUTube/ServerMUTube.
- See Also:
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.HeaderList(HeaderList that) Copy constructor.HeaderList(MessageHeaders that) HeaderList(SOAPVersion soapVersion) Creates an emptyHeaderListwith the given soap version -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds a newHeader.voidDeprecated.throws UnsupportedOperationException from some HeaderList implementations - better iterate over items one by oneprotected voidaddInternal(int index, Header header) booleanaddOrReplace(Header header) asList()ReturnsHeaderinstances in aList.static HeaderListcopy(HeaderList original) Creates a copy.static HeaderListcopy(MessageHeaders original) Creates a copy.voidfillRequestAddressingHeaders(Packet packet, AddressingVersion av, SOAPVersion sv, boolean oneway, String action) voidfillRequestAddressingHeaders(Packet packet, AddressingVersion av, SOAPVersion sv, boolean oneway, String action, boolean mustUnderstand) Creates a set of outbound WS-Addressing headers on the client with the specified Action Message Addressing Property value.voidfillRequestAddressingHeaders(WSDLPort wsdlPort, WSBinding binding, Packet packet) Creates a set of outbound WS-Addressing headers on the client with the default Action Message Addressing Property value.get(int index) Gets theHeaderat the specified index.Deprecated.Gets the firstHeaderof the specified name.Deprecated.Gets the firstHeaderof the specified name.getAction(AddressingVersion av, SOAPVersion sv) Returns the value of WS-AddressingActionheader.getFaultTo(AddressingVersion av, SOAPVersion sv) Returns the value of WS-AddressingFaultToheader.getHeaders(String nsUri) Deprecated.getHeaders(String nsUri, boolean markAsUnderstood) Gets an iteration of headersHeaderin the specified namespace, including duplicates (if any.)getHeaders(String nsUri, String localName) Deprecated.getHeaders(String nsUri, String localName, boolean markAsUnderstood) Gets all theHeaders of the specified name, including duplicates (if any.)getHeaders(QName headerName, boolean markAsUnderstood) getMessageID(AddressingVersion av, SOAPVersion sv) Returns the value of WS-AddressingMessageIDheader.Returns a Set of QNames of headers that satisfy ALL the following conditions: (a) Have mustUnderstand = true (b) have NOT been explicitly marked as understood (c) If roles argument is non-null, the header has isIgnorable = false for the roles argument and SOAP version (d) If non-null binding is passed in, are NOT understood by the binding (e) If (d) is met, the header is NOT in the knownHeaders list passed ingetRelatesTo(AddressingVersion av, SOAPVersion sv) Returns the value of WS-AddressingRelatesToheader.getReplyTo(AddressingVersion av, SOAPVersion sv) Returns the value of WS-AddressingReplyToheader.getTo(AddressingVersion av, SOAPVersion sv) Returns the value of WS-AddressingToheader.Return a Set of QNames of headers that have been explicitly marked as understood.booleanbooleanisUnderstood(int index) Returns true if aHeaderat the given index was "understood".booleanisUnderstood(Header header) True if the header has been explicitly marked understood, false otherwisebooleanisUnderstood(String nsUri, String localName) True if the header has been explicitly marked understood, false otherwisebooleanisUnderstood(QName name) True if the header has been explicitly marked understood, false otherwisevoidreadResponseAddressingHeaders(WSDLPort wsdlPort, WSBinding binding) remove(int index) Removes the firstHeaderof the specified name.booleanRemoves a single instance of the specified element from this header list, if it is present.Removes the firstHeaderof the specified name.Removes the firstHeaderof the specified name.protected HeaderremoveInternal(int index) voidvoidsetSoapVersion(SOAPVersion soapVersion) intsize()The total number of headers.voidunderstood(int index) Marks theHeaderat the specified index as "understood".voidunderstood(Header header) Deprecated.By the definition ofArrayList, this operation requires O(n) search of the array, and thus inherently inefficient.voidunderstood(String nsUri, String localName) voidunderstood(QName name) Methods inherited from class java.util.ArrayList
add, addAll, addAll, clear, clone, contains, ensureCapacity, equals, forEach, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, removeAll, removeIf, removeRange, replaceAll, retainAll, set, sort, spliterator, subList, toArray, toArray, trimToSizeMethods inherited from class java.util.AbstractCollection
containsAll, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, stream, toArrayMethods inherited from interface java.util.List
containsAll
-
Constructor Details
-
HeaderList
Deprecated.This method is deprecated - instead use this one: public HeaderList(SOAPVersion) Creates an emptyHeaderList. -
HeaderList
Creates an emptyHeaderListwith the given soap version -
HeaderList
Copy constructor. -
HeaderList
-
-
Method Details
-
size
public int size()The total number of headers. -
hasHeaders
public boolean hasHeaders()- Specified by:
hasHeadersin interfaceMessageHeaders
-
addAll
Deprecated.throws UnsupportedOperationException from some HeaderList implementations - better iterate over items one by oneAdds all the headers. -
get
-
understood
public void understood(int index) Marks theHeaderat the specified index as "understood". -
isUnderstood
public boolean isUnderstood(int index) Returns true if aHeaderat the given index was "understood". -
understood
Deprecated.Marks the specifiedHeaderas "understood".- Specified by:
understoodin interfaceMessageHeaders- Throws:
IllegalArgumentException- if the given header is notcontainedin this header.
-
get
@Nullable public Header get(@NotNull String nsUri, @NotNull String localName, boolean markAsUnderstood) Gets the firstHeaderof the specified name.- Specified by:
getin interfaceMessageHeaders- Parameters:
markAsUnderstood- If this parameter is true, the returned header will be marked as "understood".- Returns:
- null if not found.
-
get
Deprecated. -
get
Gets the firstHeaderof the specified name.- Specified by:
getin interfaceMessageHeaders- Parameters:
markAsUnderstood- If this parameter is true, the returned header will be marked as "understood".- Returns:
- null if not found.
-
get
Deprecated. -
getHeaders
Deprecated. -
getHeaders
@NotNull public Iterator<Header> getHeaders(@NotNull String nsUri, @NotNull String localName, boolean markAsUnderstood) Gets all theHeaders of the specified name, including duplicates (if any.)- Specified by:
getHeadersin interfaceMessageHeaders- Parameters:
markAsUnderstood- If this parameter is true, the returned headers will be marked as "understood" when they are returned fromIterator.next().- Returns:
- empty iterator if not found.
-
getHeaders
- Specified by:
getHeadersin interfaceMessageHeaders- See Also:
-
getHeaders
Deprecated. -
getHeaders
Gets an iteration of headersHeaderin the specified namespace, including duplicates (if any.)- Specified by:
getHeadersin interfaceMessageHeaders- Parameters:
markAsUnderstood- If this parameter is true, the returned headers will be marked as "understood" when they are returned fromIterator.next().- Returns:
- empty iterator if not found.
-
getTo
Returns the value of WS-AddressingToheader. Theversionidentifies the WS-Addressing version and the header returned is targeted at the current implicit role. Caches the value for subsequent invocation. DuplicateToheaders are detected earlier.- Parameters:
av- WS-Addressing versionsv- SOAP version- Returns:
- Value of WS-Addressing To header, anonymous URI if no header is present
- Throws:
IllegalArgumentException- if eitheravorsvis null.
-
getAction
Returns the value of WS-AddressingActionheader. Theversionidentifies the WS-Addressing version and the header returned is targeted at the current implicit role. Caches the value for subsequent invocation. DuplicateActionheaders are detected earlier.- Parameters:
av- WS-Addressing versionsv- SOAP version- Returns:
- Value of WS-Addressing Action header, null if no header is present
- Throws:
IllegalArgumentException- if eitheravorsvis null.
-
getReplyTo
Returns the value of WS-AddressingReplyToheader. Theversionidentifies the WS-Addressing version and the header returned is targeted at the current implicit role. Caches the value for subsequent invocation. DuplicateReplyToheaders are detected earlier.- Parameters:
av- WS-Addressing versionsv- SOAP version- Returns:
- Value of WS-Addressing ReplyTo header, null if no header is present
- Throws:
IllegalArgumentException- if eitheravorsvis null.
-
getFaultTo
Returns the value of WS-AddressingFaultToheader. Theversionidentifies the WS-Addressing version and the header returned is targeted at the current implicit role. Caches the value for subsequent invocation. DuplicateFaultToheaders are detected earlier.- Parameters:
av- WS-Addressing versionsv- SOAP version- Returns:
- Value of WS-Addressing FaultTo header, null if no header is present
- Throws:
IllegalArgumentException- if eitheravorsvis null.
-
getMessageID
Returns the value of WS-AddressingMessageIDheader. Theversionidentifies the WS-Addressing version and the header returned is targeted at the current implicit role. Caches the value for subsequent invocation. DuplicateMessageIDheaders are detected earlier.- Parameters:
av- WS-Addressing versionsv- SOAP version- Returns:
- Value of WS-Addressing MessageID header, null if no header is present
- Throws:
jakarta.xml.ws.WebServiceException- if eitheravorsvis null.
-
getRelatesTo
Returns the value of WS-AddressingRelatesToheader. Theversionidentifies the WS-Addressing version and the header returned is targeted at the current implicit role. Caches the value for subsequent invocation. DuplicateRelatesToheaders are detected earlier.- Parameters:
av- WS-Addressing versionsv- SOAP version- Returns:
- Value of WS-Addressing RelatesTo header, null if no header is present
- Throws:
jakarta.xml.ws.WebServiceException- if eitheravorsvis null.
-
fillRequestAddressingHeaders
public void fillRequestAddressingHeaders(Packet packet, AddressingVersion av, SOAPVersion sv, boolean oneway, String action, boolean mustUnderstand) Creates a set of outbound WS-Addressing headers on the client with the specified Action Message Addressing Property value.This method needs to be invoked right after such a Message is created which is error prone but so far only MEX, RM and JAX-WS creates a request so this ugliness is acceptable. This method is also used to create protocol messages that are not associated with any
WSBindingandWSDLPort.- Parameters:
packet- request packetav- WS-Addressing versionsv- SOAP versiononeway- Indicates if the message exchange pattern is onewayaction- Action Message Addressing Property valuemustUnderstand- to indicate if the addressing headers are set with mustUnderstand attribute
-
fillRequestAddressingHeaders
public void fillRequestAddressingHeaders(Packet packet, AddressingVersion av, SOAPVersion sv, boolean oneway, String action) -
fillRequestAddressingHeaders
public void fillRequestAddressingHeaders(WSDLPort wsdlPort, @NotNull WSBinding binding, Packet packet) Creates a set of outbound WS-Addressing headers on the client with the default Action Message Addressing Property value.This method needs to be invoked right after such a Message is created which is error prone but so far only MEX, RM and JAX-WS creates a request so this ugliness is acceptable. If more components are identified using this, then we may revisit this.
This method is used if default Action Message Addressing Property is to be used. See
fillRequestAddressingHeaders(Packet, com.sun.xml.ws.api.addressing.AddressingVersion, com.sun.xml.ws.api.SOAPVersion, boolean, String)if non-default Action is to be used, for example when creating a protocol message not associated withWSBindingandWSDLPort. This method uses SOAPAction as the Action unless set expplicitly in the wsdl.- Parameters:
wsdlPort- request WSDL portbinding- request WSBindingpacket- request packet
-
add
Adds a newHeader.Order doesn't matter in headers, so this method does not make any guarantee as to where the new header is inserted.
-
remove
Removes the firstHeaderof the specified name.- Specified by:
removein interfaceMessageHeaders- Parameters:
nsUri- namespace URI of the header to removelocalName- local part of the FQN of the header to remove- Returns:
- null if not found.
-
addOrReplace
Replaces an existingHeaderor adds a newHeader.Order doesn't matter in headers, so this method does not make any guarantee as to where the new header is inserted.
- Specified by:
addOrReplacein interfaceMessageHeaders- Returns:
- always true. Don't use the return value.
-
replace
- Specified by:
replacein interfaceMessageHeaders
-
addInternal
-
removeInternal
-
remove
Removes the firstHeaderof the specified name.- Specified by:
removein interfaceMessageHeaders- Parameters:
name- fully qualified name of the header to remove- Returns:
- null if not found.
-
remove
Removes the firstHeaderof the specified name. -
remove
Removes a single instance of the specified element from this header list, if it is present. More formally, removes a headerhsuch that(o==null ? h==null : o.equals(h)), if the header list contains one or more such headers. Returnstrueif the list contained the specified element (or equivalently, if the list changed as a result of the call). -
remove
-
copy
Creates a copy. This handles nullHeaderListcorrectly.- Parameters:
original- Can be null, in which case null will be returned.
-
copy
Creates a copy. This handles nullHeaderListcorrectly.- Parameters:
original- Can be null, in which case null will be returned.
-
readResponseAddressingHeaders
-
understood
- Specified by:
understoodin interfaceMessageHeaders
-
understood
- Specified by:
understoodin interfaceMessageHeaders
-
getUnderstoodHeaders
Description copied from interface:MessageHeadersReturn a Set of QNames of headers that have been explicitly marked as understood. If none have been marked, this method could return null- Specified by:
getUnderstoodHeadersin interfaceMessageHeaders
-
isUnderstood
Description copied from interface:MessageHeadersTrue if the header has been explicitly marked understood, false otherwise- Specified by:
isUnderstoodin interfaceMessageHeaders
-
isUnderstood
Description copied from interface:MessageHeadersTrue if the header has been explicitly marked understood, false otherwise- Specified by:
isUnderstoodin interfaceMessageHeaders
-
isUnderstood
Description copied from interface:MessageHeadersTrue if the header has been explicitly marked understood, false otherwise- Specified by:
isUnderstoodin interfaceMessageHeaders
-
getNotUnderstoodHeaders
public Set<QName> getNotUnderstoodHeaders(Set<String> roles, Set<QName> knownHeaders, WSBinding binding) Description copied from interface:MessageHeadersReturns a Set of QNames of headers that satisfy ALL the following conditions: (a) Have mustUnderstand = true (b) have NOT been explicitly marked as understood (c) If roles argument is non-null, the header has isIgnorable = false for the roles argument and SOAP version (d) If non-null binding is passed in, are NOT understood by the binding (e) If (d) is met, the header is NOT in the knownHeaders list passed in- Specified by:
getNotUnderstoodHeadersin interfaceMessageHeaders
-
setSoapVersion
-
getHeaders
- Specified by:
getHeadersin interfaceMessageHeaders
-
asList
Description copied from interface:MessageHeadersReturnsHeaderinstances in aList.- Specified by:
asListin interfaceMessageHeaders- Returns:
ListcontainingHeaderinstances
-