use of com.sun.xml.ws.api.message.Header 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;
}
use of com.sun.xml.ws.api.message.Header 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);
}
use of com.sun.xml.ws.api.message.Header in project metro-jax-ws by eclipse-ee4j.
the class StreamMessage method writeTo.
public void writeTo(ContentHandler contentHandler, ErrorHandler errorHandler) throws SAXException {
if (envelopeReader != null)
readEnvelope(this);
contentHandler.setDocumentLocator(NULL_LOCATOR);
contentHandler.startDocument();
envelopeTag.writeStart(contentHandler);
if (hasHeaders() && headerTag == null)
headerTag = new TagInfoset(envelopeTag.nsUri, "Header", envelopeTag.prefix, EMPTY_ATTS);
if (headerTag != null) {
headerTag.writeStart(contentHandler);
if (hasHeaders()) {
MessageHeaders headers = getHeaders();
for (Header h : headers.asList()) {
// shouldn't JDK be smart enough to use array-style indexing for this foreach!?
h.writeTo(contentHandler, errorHandler);
}
}
headerTag.writeEnd(contentHandler);
}
bodyTag.writeStart(contentHandler);
writePayloadTo(contentHandler, errorHandler, true);
bodyTag.writeEnd(contentHandler);
envelopeTag.writeEnd(contentHandler);
contentHandler.endDocument();
}
use of com.sun.xml.ws.api.message.Header in project metro-jax-ws by eclipse-ee4j.
the class Stub method setOutboundHeaders.
@Override
public final void setOutboundHeaders(Header... headers) {
if (headers == null) {
this.userOutboundHeaders = null;
} else {
for (Header h : headers) {
if (h == null) {
throw new IllegalArgumentException();
}
}
Header[] hl = new Header[headers.length];
System.arraycopy(headers, 0, hl, 0, headers.length);
userOutboundHeaders = hl;
}
}
use of com.sun.xml.ws.api.message.Header in project metro-jax-ws by eclipse-ee4j.
the class SAAJMessageHeadersTest method testMustUnderstand.
public void testMustUnderstand() throws Exception {
SOAPMessage sm = makeSOAPMessage(MESSAGE);
// SAAJMessage saajMsg = new SAAJMessage(sm);
MessageHeaders hdrs = new SAAJMessageHeaders(sm, SOAPVersion.SOAP_11);
// new must understand header
Header newHdr = new StringHeader(new QName("myNs", "stringHeader1"), "stringHeaderValue1", SOAPVersion.SOAP_11, true);
hdrs.add(newHdr);
Set<QName> notUnderstoods = hdrs.getNotUnderstoodHeaders(null, null, null);
assertNotNull(notUnderstoods);
assertEquals(1, notUnderstoods.size());
// verify the understood headers list
Set<QName> understoods = hdrs.getUnderstoodHeaders();
// none of the headers is marked understood
assertNull(understoods);
// assertEquals(1, understoods.size());
// the new header should not be understood yet
assertFalse(hdrs.isUnderstood(newHdr));
// now "understand" the header
hdrs.understood(newHdr);
// the new header should be understood now
assertTrue(hdrs.isUnderstood(newHdr));
notUnderstoods = hdrs.getNotUnderstoodHeaders(null, null, null);
assertNotNull(notUnderstoods);
assertEquals(0, notUnderstoods.size());
// make sure the newly understood header now shows up in the understoodHeaders
understoods = hdrs.getUnderstoodHeaders();
assertNotNull(understoods);
assertEquals(1, understoods.size());
}
Aggregations