Search in sources :

Example 1 with MessageHeaders

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

the class ActionBasedOperationFinder method getWSDLOperationMapping.

public WSDLOperationMapping getWSDLOperationMapping(Packet request) throws DispatchException {
    MessageHeaders hl = request.getMessage().getHeaders();
    String action = AddressingUtils.getAction(hl, av, binding.getSOAPVersion());
    if (action == null)
        // Addressing is not enagaged, return null to use other ways to dispatch.
        return null;
    Message message = request.getMessage();
    QName payloadName;
    String localPart = message.getPayloadLocalPart();
    if (localPart == null) {
        payloadName = PayloadQNameBasedOperationFinder.EMPTY_PAYLOAD;
    } else {
        String nsUri = message.getPayloadNamespaceURI();
        if (nsUri == null)
            nsUri = PayloadQNameBasedOperationFinder.EMPTY_PAYLOAD_NSURI;
        payloadName = new QName(nsUri, localPart);
    }
    WSDLOperationMapping opMapping = uniqueOpSignatureMap.get(new ActionBasedOperationSignature(action, payloadName));
    if (opMapping != null)
        return opMapping;
    // Seems like in Wstrust STS wsdls, the payload does not match what is specified in the wsdl leading to incorrect
    // wsdl operation resolution. Use just wsa:Action to dispatch as a last resort.
    // try just with wsa:Action
    opMapping = actionMap.get(action);
    if (opMapping != null)
        return opMapping;
    // invalid action header
    Message result = Messages.create(action, av, binding.getSOAPVersion());
    throw new DispatchException(result);
}
Also used : WSDLOperationMapping(com.sun.xml.ws.api.model.WSDLOperationMapping) Message(com.sun.xml.ws.api.message.Message) QName(javax.xml.namespace.QName) MessageHeaders(com.sun.xml.ws.api.message.MessageHeaders)

Example 2 with MessageHeaders

use of com.sun.xml.ws.api.message.MessageHeaders 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 3 with MessageHeaders

use of com.sun.xml.ws.api.message.MessageHeaders 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)

Example 4 with MessageHeaders

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

the class StatefulInstanceResolver method resolve.

@Override
@NotNull
public T resolve(Packet request) {
    MessageHeaders headers = request.getMessage().getHeaders();
    Header header = headers.get(COOKIE_TAG, true);
    String id = null;
    if (header != null) {
        // find the instance
        id = header.getStringContent();
        Instance o = haMap.get(id);
        if (o != null) {
            if (logger.isLoggable(Level.FINEST)) {
                logger.log(Level.FINEST, "Restarting timer for objectId/Instance = [ {0} / {1} ]", new Object[] { id, o });
            }
            o.restartTimer();
            return o.instance;
        }
        // huh? what is this ID?
        logger.log(Level.INFO, "Request had an unrecognized object ID {0}", id);
    } else {
        logger.fine("No objectId header received");
    }
    // need to fallback
    T flbk = this.fallback;
    if (flbk != null) {
        return flbk;
    }
    if (id == null) {
        throw new WebServiceException(ServerMessages.STATEFUL_COOKIE_HEADER_REQUIRED(COOKIE_TAG));
    } else {
        throw new WebServiceException(ServerMessages.STATEFUL_COOKIE_HEADER_INCORRECT(COOKIE_TAG, id));
    }
}
Also used : Header(com.sun.xml.ws.api.message.Header) WebServiceException(jakarta.xml.ws.WebServiceException) MessageHeaders(com.sun.xml.ws.api.message.MessageHeaders) NotNull(com.sun.istack.NotNull)

Example 5 with MessageHeaders

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

the class StreamMessage method writeToBodyStart.

public void writeToBodyStart(XMLStreamWriter writer) throws XMLStreamException {
    if (envelopeReader != null)
        readEnvelope(this);
    writer.writeStartDocument();
    envelopeTag.writeStart(writer);
    // write headers
    MessageHeaders hl = getHeaders();
    if (hl.hasHeaders() && headerTag == null)
        headerTag = new TagInfoset(envelopeTag.nsUri, "Header", envelopeTag.prefix, EMPTY_ATTS);
    if (headerTag != null) {
        headerTag.writeStart(writer);
        if (hl.hasHeaders()) {
            for (Header h : hl.asList()) {
                h.writeTo(writer);
            }
        }
        writer.writeEndElement();
    }
    bodyTag.writeStart(writer);
}
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)

Aggregations

MessageHeaders (com.sun.xml.ws.api.message.MessageHeaders)14 Header (com.sun.xml.ws.api.message.Header)10 SAAJMessageHeaders (com.sun.xml.ws.api.message.saaj.SAAJMessageHeaders)5 QName (javax.xml.namespace.QName)5 StringHeader (com.sun.xml.ws.message.StringHeader)4 SOAPMessage (jakarta.xml.soap.SOAPMessage)4 NotNull (com.sun.istack.NotNull)2 Message (com.sun.xml.ws.api.message.Message)2 TagInfoset (com.sun.xml.ws.encoding.TagInfoset)2 InvalidAddressingHeaderException (com.sun.xml.ws.addressing.model.InvalidAddressingHeaderException)1 Packet (com.sun.xml.ws.api.message.Packet)1 WSDLOperationMapping (com.sun.xml.ws.api.model.WSDLOperationMapping)1 FaultDetailHeader (com.sun.xml.ws.message.FaultDetailHeader)1 StreamHeader11 (com.sun.xml.ws.message.stream.StreamHeader11)1 SOAPFault (jakarta.xml.soap.SOAPFault)1 SOAPHeaderElement (jakarta.xml.soap.SOAPHeaderElement)1 WebServiceException (jakarta.xml.ws.WebServiceException)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 XMLStreamReader (javax.xml.stream.XMLStreamReader)1