Search in sources :

Example 1 with Header

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;
}
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 Header

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);
}
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 3 with Header

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();
}
Also used : Header(com.sun.xml.ws.api.message.Header) TagInfoset(com.sun.xml.ws.encoding.TagInfoset) MessageHeaders(com.sun.xml.ws.api.message.MessageHeaders)

Example 4 with Header

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;
    }
}
Also used : Header(com.sun.xml.ws.api.message.Header)

Example 5 with Header

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());
}
Also used : SAAJMessageHeaders(com.sun.xml.ws.api.message.saaj.SAAJMessageHeaders) StringHeader(com.sun.xml.ws.message.StringHeader) StringHeader(com.sun.xml.ws.message.StringHeader) Header(com.sun.xml.ws.api.message.Header) QName(javax.xml.namespace.QName) SAAJMessageHeaders(com.sun.xml.ws.api.message.saaj.SAAJMessageHeaders) MessageHeaders(com.sun.xml.ws.api.message.MessageHeaders) SOAPMessage(jakarta.xml.soap.SOAPMessage)

Aggregations

Header (com.sun.xml.ws.api.message.Header)31 MessageHeaders (com.sun.xml.ws.api.message.MessageHeaders)10 QName (javax.xml.namespace.QName)9 StringHeader (com.sun.xml.ws.message.StringHeader)8 ArrayList (java.util.ArrayList)6 SOAPMessage (jakarta.xml.soap.SOAPMessage)5 WebServiceException (jakarta.xml.ws.WebServiceException)5 SAAJMessageHeaders (com.sun.xml.ws.api.message.saaj.SAAJMessageHeaders)4 XMLReaderComposite (com.sun.xml.ws.util.xml.XMLReaderComposite)4 ElemInfo (com.sun.xml.ws.util.xml.XMLReaderComposite.ElemInfo)4 Message (com.sun.xml.ws.api.message.Message)3 WSBindingProvider (com.sun.xml.ws.developer.WSBindingProvider)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3 XMLStreamException (javax.xml.stream.XMLStreamException)3 XMLStreamReader (javax.xml.stream.XMLStreamReader)3 InvalidAddressingHeaderException (com.sun.xml.ws.addressing.model.InvalidAddressingHeaderException)2 Component (com.sun.xml.ws.api.Component)2 EndpointAddress (com.sun.xml.ws.api.EndpointAddress)2 WSBinding (com.sun.xml.ws.api.WSBinding)2 WSEndpointReference (com.sun.xml.ws.api.addressing.WSEndpointReference)2