Jakarta XML Web Services (JAX-WS) runtime implementation providing comprehensive SOAP web service capabilities
—
Central message processing APIs providing SOAP message abstraction, pipeline processing, attachment handling, and header management. These APIs form the foundation for all web service communication in JAX-WS.
Core SOAP message representation supporting various formats and providing unified access to message content.
/**
* Abstract representation of a SOAP message with support for various formats and operations
*/
package com.sun.xml.ws.api.message;
public abstract class Message {
/** Check if message has a payload body */
public abstract boolean hasPayload();
/** Get payload local name */
public abstract String getPayloadLocalPart();
/** Get payload namespace URI */
public abstract String getPayloadNamespaceURI();
/** Check if message is a SOAP fault */
public abstract boolean isFault();
/** Get first detail entry name for faults */
public abstract QName getFirstDetailEntryName();
/** Read payload as XML Source for processing */
public abstract Source readPayloadAsSource();
/** Read entire envelope as XML Source */
public abstract Source readEnvelopeAsSource();
/** Read payload as XMLStreamReader */
public abstract XMLStreamReader readPayload() throws XMLStreamException;
/** Read payload as JAXB object */
public abstract <T> T readPayloadAsJAXB(Unmarshaller unmarshaller) throws JAXBException;
/** Read payload as JAXB object using Bridge */
public abstract <T> T readPayloadAsJAXB(Bridge<T> bridge) throws JAXBException;
/** Read payload as JAXB object using XMLBridge */
public abstract <T> T readPayloadAsJAXB(XMLBridge<T> bridge) throws JAXBException;
/** Convert to SAAJ SOAPMessage for compatibility */
public abstract SOAPMessage readAsSOAPMessage() throws SOAPException;
/** Write message content to SAX ContentHandler */
public abstract void writeTo(ContentHandler contentHandler, ErrorHandler errorHandler) throws SAXException;
/** Write message to XMLStreamWriter */
public abstract void writeTo(XMLStreamWriter writer) throws XMLStreamException;
/** Write payload to XMLStreamWriter */
public abstract void writePayloadTo(XMLStreamWriter writer) throws XMLStreamException;
/** Get SOAP version */
public final SOAPVersion getSOAPVersion();
/** Get message headers */
public abstract MessageHeaders getHeaders();
/** Get collection of MIME attachments */
public abstract AttachmentSet getAttachments();
/** Check if message has attachments */
protected boolean hasAttachments();
/** Consume message (makes it no longer readable) */
public abstract void consume();
/** Create copy of message */
public abstract Message copy();
/** Get unique message ID */
public String getID(SOAPVersion soapVersion, AddressingVersion addressingVersion);
}Factory methods for creating various types of messages.
/**
* Factory class for creating Message instances from various sources
*/
public final class Messages {
/** Create message from JAXB object */
public static Message create(JAXBContext jaxbContext, Object jaxbObject, SOAPVersion soapVersion);
/** Create message from XML Source */
public static Message create(Source source, SOAPVersion soapVersion);
/** Create message from SOAPMessage */
public static Message create(SOAPMessage soapMessage);
/** Create empty message */
public static Message createEmpty(SOAPVersion soapVersion);
/** Create fault message */
public static Message create(SOAPFault fault);
}Container for messages with associated metadata and processing context.
/**
* Container for SOAP message with associated metadata, properties, and processing context.
* Extends BaseDistributedPropertySet and implements MessageContext and MessageMetadata.
*/
public final class Packet extends BaseDistributedPropertySet
implements MessageContext, MessageMetadata {
/** Get the SOAP message */
public Message getMessage();
/** Set the SOAP message */
public void setMessage(Message msg);
/** Get properties as Map including invocation properties */
public Map<String, Object> asMapIncludingInvocationProperties();
/** Get strongly-typed satellite object (inherited) */
public <T> T getSatellite(Class<T> satelliteClass);
/** Set satellite object (inherited) */
public <T> void setSatellite(Class<T> satelliteClass, T satellite);
/** Create client response packet */
public Packet createClientResponse(Message responseMessage);
/** Create server response packet */
public Packet createServerResponse(@Nullable Message responseMessage,
@NotNull QName wsdlOperationName,
@NotNull WSDLPort wsdlPort,
@NotNull SEIModel seiModel,
@NotNull WSBinding binding);
/** Copy packet with optional message copying */
public Packet copy(boolean copyMessage);
/** Get endpoint address */
public @NotNull EndpointAddress getEndpointAddress();
/** Set endpoint address */
public void setEndpointAddress(@NotNull EndpointAddress address);
/** Get WSDL operation name */
public @Nullable QName getWSDLOperation();
/** Set WSDL operation name */
public void setWSDLOperation(@Nullable QName wsdlOp);
/** Check if packet represents a request */
public boolean isRequestMessage;
/** Check if transport is synchronous */
public Boolean transportBackChannel;
/** Get content negotiation property map */
public ContentNegotiation contentNegotiation;
}Header management for SOAP messages with support for various header formats.
/**
* Individual SOAP header representation
*/
public abstract class Header {
/** Get header element name */
public abstract QName getName();
/** Get namespace URI */
public String getNamespaceURI();
/** Get local name */
public String getLocalPart();
/** Check if header is targeted to role */
public abstract boolean isTargetedToRole(Set<String> roles, SOAPVersion soapVersion);
/** Read header as XML Source */
public abstract Source readAsSource();
/** Read header as JAXB object */
public abstract <T> T readAsJAXB(JAXBContext jaxbContext) throws JAXBException;
/** Write header to XMLStreamWriter */
public abstract void writeTo(XMLStreamWriter writer) throws XMLStreamException;
}
/**
* Collection of SOAP headers with management operations.
* Extends ArrayList and implements MessageHeaders interface.
*/
public final class HeaderList extends ArrayList<Header> implements MessageHeaders {
/** Add header to collection */
public void add(Header header);
/** Get header by name */
public Header get(QName name, boolean markAsUnderstood);
/** Get header by namespace and local name */
public Header get(String nsUri, String localName, boolean markAsUnderstood);
/** Get all headers for namespace */
public List<Header> getHeaders(String nsUri);
/** Get all headers for namespace and local name */
public List<Header> getHeaders(String nsUri, String localName);
/** Remove header by QName */
public boolean remove(QName name);
/** Remove header by namespace and local name */
public boolean remove(String nsUri, String localName);
/** Check if headers exist */
public boolean hasHeaders();
/** Get iterator over headers */
public Iterator<Header> iterator();
/** Mark header as understood */
public void understood(QName name);
/** Mark header as understood by namespace and local name */
public void understood(String nsUri, String localName);
/** Get headers not understood */
public Set<QName> getNotUnderstoodHeaders(Set<String> roles, Set<QName> knownHeaders, WSBinding binding);
}Factory methods for creating various types of headers.
/**
* Factory methods for creating SOAP headers
*/
public final class Headers {
/** Create header from JAXB object */
public static Header create(JAXBContext jaxbContext, Object jaxbObject) throws JAXBException;
/** Create header from XML Source */
public static Header create(QName name, Source source);
/** Create string-based header */
public static Header create(QName name, String value);
/** Create header from DOM Element */
public static Header create(Element element);
}Asynchronous processing pipeline with tube-based architecture.
/**
* Asynchronous processing unit in message pipeline
*/
package com.sun.xml.ws.api.pipe;
public interface Tube {
/** Process request packet and return next action */
NextAction processRequest(Packet request);
/** Process response packet and return next action */
NextAction processResponse(Packet response);
/** Pre-destroy cleanup */
void preDestroy();
/** Create copy of tube */
Tube copy(TubeCloner cloner);
}
/**
* Next action in pipeline processing - final class with instance methods
*/
public final class NextAction {
/** Continue processing with next tube */
public NextAction invoke(Tube next, Packet packet);
/** Suspend processing and resume later */
public NextAction suspend(Packet packet, Runnable onResume);
/** Suspend with fiber and runnable */
public NextAction suspend(Packet packet, Fiber.CompletionCallback onResume);
/** Return response immediately */
public NextAction returnWith(Packet response);
/** Throw exception */
public NextAction throwException(Throwable throwable);
/** Get the packet associated with this action */
public Packet getPacket();
/** Get the next tube to invoke */
public Tube getNext();
/** Get throwable if action is to throw exception */
public Throwable getThrowable();
/** Check if this action suspends processing */
public boolean isSuspend();
/** Check if this action returns a response */
public boolean isReturn();
/** Check if this action throws an exception */
public boolean isThrow();
/** Check if this action invokes next tube */
public boolean isInvoke();
}Message encoding and decoding between different formats.
/**
* Encodes/decodes SOAP messages to/from transport format
*/
public interface Codec {
/** Get MIME content type for encoding */
String getMimeType();
/** Get supported content types for decoding */
ContentType getStaticContentType(Packet packet);
/** Encode packet to output stream */
ContentType encode(Packet packet, OutputStream out) throws IOException;
/** Decode input stream to packet */
void decode(InputStream in, String contentType, Packet packet) throws IOException;
/** Create copy of codec */
Codec copy();
}MIME attachment support for SOAP messages.
/**
* MIME attachment representation
*/
package com.sun.xml.ws.api.message;
public interface Attachment {
/** Get Content-ID header value */
String getContentId();
/** Get Content-Type header value */
String getContentType();
/** Get attachment content as byte array */
byte[] asByteArray();
/** Get attachment as DataHandler */
DataHandler asDataHandler();
/** Get attachment as XML Source */
Source asSource();
/** Get attachment as InputStream */
InputStream asInputStream();
/** Write attachment to OutputStream */
void writeTo(OutputStream os) throws IOException;
}
/**
* Collection of attachments with management operations
*/
public interface AttachmentSet extends Iterable<Attachment> {
/** Get attachment by Content-ID */
Attachment get(String contentId);
/** Check if attachments exist */
boolean isEmpty();
/** Add attachment */
void add(Attachment attachment);
/** Get iterator over attachments */
Iterator<Attachment> iterator();
}Usage Examples:
import com.sun.xml.ws.api.message.*;
import com.sun.xml.ws.api.pipe.*;
// Create message from JAXB object
JAXBContext jaxbContext = JAXBContext.newInstance(MyRequestType.class);
MyRequestType request = new MyRequestType();
Message message = Messages.create(jaxbContext, request, SOAPVersion.SOAP_11);
// Add custom header
HeaderList headers = message.getHeaders();
Header customHeader = Headers.create(new QName("http://example.com", "CustomHeader"), "value");
headers.add(customHeader);
// Create packet with message
Packet packet = new Packet(message);
packet.put("custom.property", "value");
// Process through tube pipeline
public class MyTube implements Tube {
private Tube next;
public NextAction processRequest(Packet request) {
// Process request
Message msg = request.getMessage();
if (msg.hasPayload()) {
// Handle request logic
}
// Continue to next tube
return NextAction.invoke(next, request);
}
public NextAction processResponse(Packet response) {
// Process response
return NextAction.returnWith(response);
}
}Install with Tessl CLI
npx tessl i tessl/maven-com-sun-xml-ws--jaxws-rt