com.sun.xml.internal.ws.api.message.MessageHeaders Java Examples

The following examples show how to use com.sun.xml.internal.ws.api.message.MessageHeaders. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractMessageImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Writes the whole envelope as SAX events.
 */
@Override
public void writeTo( ContentHandler contentHandler, ErrorHandler errorHandler ) throws SAXException {
    String soapNsUri = soapVersion.nsUri;

    contentHandler.setDocumentLocator(NULL_LOCATOR);
    contentHandler.startDocument();
    contentHandler.startPrefixMapping("S",soapNsUri);
    contentHandler.startElement(soapNsUri,"Envelope","S:Envelope",EMPTY_ATTS);
    if(hasHeaders()) {
        contentHandler.startElement(soapNsUri,"Header","S:Header",EMPTY_ATTS);
        MessageHeaders headers = getHeaders();
        for (Header h : headers.asList()) {
            h.writeTo(contentHandler,errorHandler);
        }
        contentHandler.endElement(soapNsUri,"Header","S:Header");
    }
    // write the body
    contentHandler.startElement(soapNsUri,"Body","S:Body",EMPTY_ATTS);
    writePayloadTo(contentHandler,errorHandler, true);
    contentHandler.endElement(soapNsUri,"Body","S:Body");
    contentHandler.endElement(soapNsUri,"Envelope","S:Envelope");
}
 
Example #2
Source File: AbstractMessageImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Default implementation that relies on {@link #writePayloadTo(XMLStreamWriter)}
 */
@Override
public void writeTo(XMLStreamWriter w) throws XMLStreamException {
    String soapNsUri = soapVersion.nsUri;
    w.writeStartDocument();
    w.writeStartElement("S","Envelope",soapNsUri);
    w.writeNamespace("S",soapNsUri);
    if(hasHeaders()) {
        w.writeStartElement("S","Header",soapNsUri);
        MessageHeaders headers = getHeaders();
        for (Header h : headers.asList()) {
            h.writeTo(w);
        }
        w.writeEndElement();
    }
    // write the body
    w.writeStartElement("S","Body",soapNsUri);

    writePayloadTo(w);

    w.writeEndElement();
    w.writeEndElement();
    w.writeEndDocument();
}
 
Example #3
Source File: AbstractMessageImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void writeToBodyStart(XMLStreamWriter w) throws XMLStreamException {
    String soapNsUri = soapVersion.nsUri;
    w.writeStartDocument();
    w.writeStartElement("S","Envelope",soapNsUri);
    w.writeNamespace("S",soapNsUri);
    if(hasHeaders()) {
        w.writeStartElement("S","Header",soapNsUri);
        MessageHeaders headers = getHeaders();
        for (Header h : headers.asList()) {
            h.writeTo(w);
        }
        w.writeEndElement();
    }
    // write the body
    w.writeStartElement("S","Body",soapNsUri);
}
 
Example #4
Source File: AbstractMessageImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Default implementation that relies on {@link #writePayloadTo(XMLStreamWriter)}
 */
@Override
public void writeTo(XMLStreamWriter w) throws XMLStreamException {
    String soapNsUri = soapVersion.nsUri;
    w.writeStartDocument();
    w.writeStartElement("S","Envelope",soapNsUri);
    w.writeNamespace("S",soapNsUri);
    if(hasHeaders()) {
        w.writeStartElement("S","Header",soapNsUri);
        MessageHeaders headers = getHeaders();
        for (Header h : headers.asList()) {
            h.writeTo(w);
        }
        w.writeEndElement();
    }
    // write the body
    w.writeStartElement("S","Body",soapNsUri);

    writePayloadTo(w);

    w.writeEndElement();
    w.writeEndElement();
    w.writeEndDocument();
}
 
Example #5
Source File: AbstractMessageImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Writes the whole envelope as SAX events.
 */
@Override
public void writeTo( ContentHandler contentHandler, ErrorHandler errorHandler ) throws SAXException {
    String soapNsUri = soapVersion.nsUri;

    contentHandler.setDocumentLocator(NULL_LOCATOR);
    contentHandler.startDocument();
    contentHandler.startPrefixMapping("S",soapNsUri);
    contentHandler.startElement(soapNsUri,"Envelope","S:Envelope",EMPTY_ATTS);
    if(hasHeaders()) {
        contentHandler.startElement(soapNsUri,"Header","S:Header",EMPTY_ATTS);
        MessageHeaders headers = getHeaders();
        for (Header h : headers.asList()) {
            h.writeTo(contentHandler,errorHandler);
        }
        contentHandler.endElement(soapNsUri,"Header","S:Header");
    }
    // write the body
    contentHandler.startElement(soapNsUri,"Body","S:Body",EMPTY_ATTS);
    writePayloadTo(contentHandler,errorHandler, true);
    contentHandler.endElement(soapNsUri,"Body","S:Body");
    contentHandler.endElement(soapNsUri,"Envelope","S:Envelope");
}
 
Example #6
Source File: AbstractMessageImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Default implementation that relies on {@link #writePayloadTo(XMLStreamWriter)}
 */
@Override
public void writeTo(XMLStreamWriter w) throws XMLStreamException {
    String soapNsUri = soapVersion.nsUri;
    w.writeStartDocument();
    w.writeStartElement("S","Envelope",soapNsUri);
    w.writeNamespace("S",soapNsUri);
    if(hasHeaders()) {
        w.writeStartElement("S","Header",soapNsUri);
        MessageHeaders headers = getHeaders();
        for (Header h : headers.asList()) {
            h.writeTo(w);
        }
        w.writeEndElement();
    }
    // write the body
    w.writeStartElement("S","Body",soapNsUri);

    writePayloadTo(w);

    w.writeEndElement();
    w.writeEndElement();
    w.writeEndDocument();
}
 
Example #7
Source File: AbstractMessageImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Default implementation that relies on {@link #writePayloadTo(XMLStreamWriter)}
 */
@Override
public void writeTo(XMLStreamWriter w) throws XMLStreamException {
    String soapNsUri = soapVersion.nsUri;
    w.writeStartDocument();
    w.writeStartElement("S","Envelope",soapNsUri);
    w.writeNamespace("S",soapNsUri);
    if(hasHeaders()) {
        w.writeStartElement("S","Header",soapNsUri);
        MessageHeaders headers = getHeaders();
        for (Header h : headers.asList()) {
            h.writeTo(w);
        }
        w.writeEndElement();
    }
    // write the body
    w.writeStartElement("S","Body",soapNsUri);

    writePayloadTo(w);

    w.writeEndElement();
    w.writeEndElement();
    w.writeEndDocument();
}
 
Example #8
Source File: AbstractMessageImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Default implementation that relies on {@link #writePayloadTo(XMLStreamWriter)}
 */
@Override
public void writeTo(XMLStreamWriter w) throws XMLStreamException {
    String soapNsUri = soapVersion.nsUri;
    w.writeStartDocument();
    w.writeStartElement("S","Envelope",soapNsUri);
    w.writeNamespace("S",soapNsUri);
    if(hasHeaders()) {
        w.writeStartElement("S","Header",soapNsUri);
        MessageHeaders headers = getHeaders();
        for (Header h : headers.asList()) {
            h.writeTo(w);
        }
        w.writeEndElement();
    }
    // write the body
    w.writeStartElement("S","Body",soapNsUri);

    writePayloadTo(w);

    w.writeEndElement();
    w.writeEndElement();
    w.writeEndDocument();
}
 
Example #9
Source File: AbstractMessageImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Writes the whole envelope as SAX events.
 */
@Override
public void writeTo( ContentHandler contentHandler, ErrorHandler errorHandler ) throws SAXException {
    String soapNsUri = soapVersion.nsUri;

    contentHandler.setDocumentLocator(NULL_LOCATOR);
    contentHandler.startDocument();
    contentHandler.startPrefixMapping("S",soapNsUri);
    contentHandler.startElement(soapNsUri,"Envelope","S:Envelope",EMPTY_ATTS);
    if(hasHeaders()) {
        contentHandler.startElement(soapNsUri,"Header","S:Header",EMPTY_ATTS);
        MessageHeaders headers = getHeaders();
        for (Header h : headers.asList()) {
            h.writeTo(contentHandler,errorHandler);
        }
        contentHandler.endElement(soapNsUri,"Header","S:Header");
    }
    // write the body
    contentHandler.startElement(soapNsUri,"Body","S:Body",EMPTY_ATTS);
    writePayloadTo(contentHandler,errorHandler, true);
    contentHandler.endElement(soapNsUri,"Body","S:Body");
    contentHandler.endElement(soapNsUri,"Envelope","S:Envelope");
}
 
Example #10
Source File: LogicalMessageImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public Message getMessage(MessageHeaders headers, AttachmentSet attachments, WSBinding binding) {
    Node n = dom.getNode();
    if(n.getNodeType()== Node.DOCUMENT_NODE) {
        n = ((Document)n).getDocumentElement();
    }
    return new DOMMessage(binding.getSOAPVersion(), headers, (Element)n, attachments);
}
 
Example #11
Source File: JAXBMessage.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private JAXBMessage( BindingContext context, Object jaxbObject, SOAPVersion soapVer, MessageHeaders headers, AttachmentSet attachments ) {
        super(soapVer);
//        this.bridge = new MarshallerBridge(context);
        this.bridge = context.createFragmentBridge();
        this.rawContext = null;
        this.jaxbObject = jaxbObject;
        this.headers = headers;
        this.attachmentSet = attachments;
    }
 
Example #12
Source File: PayloadSourceMessage.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public PayloadSourceMessage(@Nullable MessageHeaders headers,
    @NotNull Source payload, @NotNull AttachmentSet attSet,
    @NotNull SOAPVersion soapVersion) {

    super(headers, SourceReaderFactory.createSourceReader(payload, true),
            attSet, soapVersion);
}
 
Example #13
Source File: Stub.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void configureRequestPacket(Packet packet, RequestContext requestContext) {
    // fill in Packet
    packet.proxy = this;
    packet.handlerConfig = binding.getHandlerConfig();

    // to make it multi-thread safe we need to first get a stable snapshot
    Header[] hl = userOutboundHeaders;
    if (hl != null) {
        MessageHeaders mh = packet.getMessage().getHeaders();
        for (Header h : hl) {
            mh.add(h);
        }
    }

    requestContext.fill(packet, (binding.getAddressingVersion() != null));
    packet.addSatellite(wsdlProperties);

    if (addrVersion != null) {
        // populate request WS-Addressing headers
        MessageHeaders headerList = packet.getMessage().getHeaders();
        AddressingUtils.fillRequestAddressingHeaders(headerList, wsdlPort, binding, packet);


        // Spec is not clear on if ReferenceParameters are to be added when addressing is not enabled,
        // but the EPR has ReferenceParameters.
        // Current approach: Add ReferenceParameters only if addressing enabled.
        if (endpointReference != null) {
            endpointReference.addReferenceParametersToList(packet.getMessage().getHeaders());
        }
    }
}
 
Example #14
Source File: StreamMessage.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void init(@Nullable MessageHeaders headers, @NotNull AttachmentSet attachmentSet, @NotNull XMLStreamReader reader, @NotNull SOAPVersion soapVersion) {
    this.headers = headers;
    this.attachmentSet = attachmentSet;
    this.reader = reader;

    if(reader.getEventType()== START_DOCUMENT)
        XMLStreamReaderUtil.nextElementContent(reader);

    //if the reader is pointing to the end element </soapenv:Body> then its empty message
    // or no payload
    if(reader.getEventType() == XMLStreamConstants.END_ELEMENT){
        String body = reader.getLocalName();
        String nsUri = reader.getNamespaceURI();
        assert body != null;
        assert nsUri != null;
        //if its not soapenv:Body then throw exception, we received malformed stream
        if(body.equals("Body") && nsUri.equals(soapVersion.nsUri)){
            this.payloadLocalName = null;
            this.payloadNamespaceURI = null;
        }else{ //TODO: i18n and also we should be throwing better message that this
            throw new WebServiceException("Malformed stream: {"+nsUri+"}"+body);
        }
    }else{
        this.payloadLocalName = reader.getLocalName();
        this.payloadNamespaceURI = reader.getNamespaceURI();
    }

    // use the default infoset representation for headers
    int base = soapVersion.ordinal()*3;
    this.envelopeTag = DEFAULT_TAGS.get(base);
    this.headerTag = DEFAULT_TAGS.get(base+1);
    this.bodyTag = DEFAULT_TAGS.get(base+2);
}
 
Example #15
Source File: JAXBMessage.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private JAXBMessage( BindingContext context, Object jaxbObject, SOAPVersion soapVer, MessageHeaders headers, AttachmentSet attachments ) {
        super(soapVer);
//        this.bridge = new MarshallerBridge(context);
        this.bridge = context.createFragmentBridge();
        this.rawContext = null;
        this.jaxbObject = jaxbObject;
        this.headers = headers;
        this.attachmentSet = attachments;
    }
 
Example #16
Source File: StreamMessage.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private void init(@NotNull TagInfoset envelopeTag, @Nullable TagInfoset headerTag, @NotNull AttachmentSet attachmentSet, @Nullable MessageHeaders headers, @Nullable String bodyPrologue, @NotNull TagInfoset bodyTag, @Nullable String bodyEpilogue, @NotNull XMLStreamReader reader, @NotNull SOAPVersion soapVersion) {
    init(headers,attachmentSet,reader,soapVersion);
    if(envelopeTag == null ) {
        throw new IllegalArgumentException("EnvelopeTag TagInfoset cannot be null");
    }
    if(bodyTag == null ) {
        throw new IllegalArgumentException("BodyTag TagInfoset cannot be null");
    }
    this.envelopeTag = envelopeTag;
    this.headerTag = headerTag;
    this.bodyTag = bodyTag;
    this.bodyPrologue = bodyPrologue;
    this.bodyEpilogue = bodyEpilogue;
}
 
Example #17
Source File: JAXBMessage.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private JAXBMessage( JAXBContext rawContext, Object jaxbObject, SOAPVersion soapVer, MessageHeaders headers, AttachmentSet attachments ) {
        super(soapVer);
//        this.bridge = new MarshallerBridge(context);
        this.rawContext = rawContext;
        this.bridge = null;
        this.jaxbObject = jaxbObject;
        this.headers = headers;
        this.attachmentSet = attachments;
    }
 
Example #18
Source File: JAXBMessage.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private JAXBMessage( BindingContext context, Object jaxbObject, SOAPVersion soapVer, MessageHeaders headers, AttachmentSet attachments ) {
        super(soapVer);
//        this.bridge = new MarshallerBridge(context);
        this.bridge = context.createFragmentBridge();
        this.rawContext = null;
        this.jaxbObject = jaxbObject;
        this.headers = headers;
        this.attachmentSet = attachments;
    }
 
Example #19
Source File: LogicalMessageImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This should be called by first checking if the payload is modified.
 *
 * @param headers
 * @param attachments
 * @param binding
 * @return
 */
public Message getMessage(MessageHeaders headers, AttachmentSet attachments, WSBinding binding) {
    assert isPayloadModifed();
    if(isPayloadModifed()) {
        return lm.getMessage(headers,attachments,binding);
    } else {
        return packet.getMessage();
    }

}
 
Example #20
Source File: LogicalMessageImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This should be called by first checking if the payload is modified.
 *
 * @param headers
 * @param attachments
 * @param binding
 * @return
 */
public Message getMessage(MessageHeaders headers, AttachmentSet attachments, WSBinding binding) {
    assert isPayloadModifed();
    if(isPayloadModifed()) {
        return lm.getMessage(headers,attachments,binding);
    } else {
        return packet.getMessage();
    }

}
 
Example #21
Source File: LogicalMessageImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public Message getMessage(MessageHeaders headers, AttachmentSet attachments, WSBinding binding) {
    Node n = dom.getNode();
    if(n.getNodeType()== Node.DOCUMENT_NODE) {
        n = ((Document)n).getDocumentElement();
    }
    return new DOMMessage(binding.getSOAPVersion(), headers, (Element)n, attachments);
}
 
Example #22
Source File: Stub.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private void configureRequestPacket(Packet packet, RequestContext requestContext) {
    // fill in Packet
    packet.proxy = this;
    packet.handlerConfig = binding.getHandlerConfig();

    // to make it multi-thread safe we need to first get a stable snapshot
    Header[] hl = userOutboundHeaders;
    if (hl != null) {
        MessageHeaders mh = packet.getMessage().getHeaders();
        for (Header h : hl) {
            mh.add(h);
        }
    }

    requestContext.fill(packet, (binding.getAddressingVersion() != null));
    packet.addSatellite(wsdlProperties);

    if (addrVersion != null) {
        // populate request WS-Addressing headers
        MessageHeaders headerList = packet.getMessage().getHeaders();
        AddressingUtils.fillRequestAddressingHeaders(headerList, wsdlPort, binding, packet);


        // Spec is not clear on if ReferenceParameters are to be added when addressing is not enabled,
        // but the EPR has ReferenceParameters.
        // Current approach: Add ReferenceParameters only if addressing enabled.
        if (endpointReference != null) {
            endpointReference.addReferenceParametersToList(packet.getMessage().getHeaders());
        }
    }
}
 
Example #23
Source File: LogicalMessageImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This should be called by first checking if the payload is modified.
 *
 * @param headers
 * @param attachments
 * @param binding
 * @return
 */
public Message getMessage(MessageHeaders headers, AttachmentSet attachments, WSBinding binding) {
    assert isPayloadModifed();
    if(isPayloadModifed()) {
        return lm.getMessage(headers,attachments,binding);
    } else {
        return packet.getMessage();
    }

}
 
Example #24
Source File: LogicalMessageImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This should be called by first checking if the payload is modified.
 *
 * @param headers
 * @param attachments
 * @param binding
 * @return
 */
public Message getMessage(MessageHeaders headers, AttachmentSet attachments, WSBinding binding) {
    assert isPayloadModifed();
    if(isPayloadModifed()) {
        return lm.getMessage(headers,attachments,binding);
    } else {
        return packet.getMessage();
    }

}
 
Example #25
Source File: PayloadSourceMessage.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public PayloadSourceMessage(@Nullable MessageHeaders headers,
    @NotNull Source payload, @NotNull AttachmentSet attSet,
    @NotNull SOAPVersion soapVersion) {

    super(headers, SourceReaderFactory.createSourceReader(payload, true),
            attSet, soapVersion);
}
 
Example #26
Source File: PayloadSourceMessage.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public PayloadSourceMessage(@Nullable MessageHeaders headers,
    @NotNull Source payload, @NotNull AttachmentSet attSet,
    @NotNull SOAPVersion soapVersion) {

    super(headers, SourceReaderFactory.createSourceReader(payload, true),
            attSet, soapVersion);
}
 
Example #27
Source File: StreamMessage.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void init(@Nullable MessageHeaders headers, @NotNull AttachmentSet attachmentSet, @NotNull XMLStreamReader reader, @NotNull SOAPVersion soapVersion) {
    this.headers = headers;
    this.attachmentSet = attachmentSet;
    this.reader = reader;

    if(reader.getEventType()== START_DOCUMENT)
        XMLStreamReaderUtil.nextElementContent(reader);

    //if the reader is pointing to the end element </soapenv:Body> then its empty message
    // or no payload
    if(reader.getEventType() == XMLStreamConstants.END_ELEMENT){
        String body = reader.getLocalName();
        String nsUri = reader.getNamespaceURI();
        assert body != null;
        assert nsUri != null;
        //if its not soapenv:Body then throw exception, we received malformed stream
        if(body.equals("Body") && nsUri.equals(soapVersion.nsUri)){
            this.payloadLocalName = null;
            this.payloadNamespaceURI = null;
        }else{ //TODO: i18n and also we should be throwing better message that this
            throw new WebServiceException("Malformed stream: {"+nsUri+"}"+body);
        }
    }else{
        this.payloadLocalName = reader.getLocalName();
        this.payloadNamespaceURI = reader.getNamespaceURI();
    }

    // use the default infoset representation for headers
    int base = soapVersion.ordinal()*3;
    this.envelopeTag = DEFAULT_TAGS.get(base);
    this.headerTag = DEFAULT_TAGS.get(base+1);
    this.bodyTag = DEFAULT_TAGS.get(base+2);
}
 
Example #28
Source File: LogicalMessageImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public Message getMessage(MessageHeaders headers, AttachmentSet attachments, WSBinding binding) {
    Node n = dom.getNode();
    if(n.getNodeType()== Node.DOCUMENT_NODE) {
        n = ((Document)n).getDocumentElement();
    }
    return new DOMMessage(binding.getSOAPVersion(), headers, (Element)n, attachments);
}
 
Example #29
Source File: StreamMessage.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void init(@NotNull TagInfoset envelopeTag, @Nullable TagInfoset headerTag, @NotNull AttachmentSet attachmentSet, @Nullable MessageHeaders headers, @Nullable String bodyPrologue, @NotNull TagInfoset bodyTag, @Nullable String bodyEpilogue, @NotNull XMLStreamReader reader, @NotNull SOAPVersion soapVersion) {
    init(headers,attachmentSet,reader,soapVersion);
    if(envelopeTag == null ) {
        throw new IllegalArgumentException("EnvelopeTag TagInfoset cannot be null");
    }
    if(bodyTag == null ) {
        throw new IllegalArgumentException("BodyTag TagInfoset cannot be null");
    }
    this.envelopeTag = envelopeTag;
    this.headerTag = headerTag;
    this.bodyTag = bodyTag;
    this.bodyPrologue = bodyPrologue;
    this.bodyEpilogue = bodyEpilogue;
}
 
Example #30
Source File: JAXBMessage.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private JAXBMessage( JAXBContext rawContext, Object jaxbObject, SOAPVersion soapVer, MessageHeaders headers, AttachmentSet attachments ) {
        super(soapVer);
//        this.bridge = new MarshallerBridge(context);
        this.rawContext = rawContext;
        this.bridge = null;
        this.jaxbObject = jaxbObject;
        this.headers = headers;
        this.attachmentSet = attachments;
    }