Jakarta XML Web Services (JAX-WS) runtime implementation providing comprehensive SOAP web service capabilities
—
HTTP transport implementation and servlet container integration providing comprehensive support for various hosting scenarios including standalone HTTP servers, servlet containers, and application servers.
Core HTTP transport implementation providing direct HTTP server support and connection abstraction.
/**
* HTTP-specific adapter for processing HTTP requests
*/
package com.sun.xml.ws.transport.http;
public final class HttpAdapter extends Adapter<WSHTTPConnection> {
/** Create standalone HTTP adapter */
public static HttpAdapter createAlone(WSEndpoint<?> endpoint, Map<String, String> urlPattern);
/** Create adapter with specified name */
public static HttpAdapter create(WSEndpoint<?> endpoint, Container container, String name);
/** Handle HTTP connection and process request */
public void handle(WSHTTPConnection connection) throws IOException;
/** Publish WSDL document for GET requests */
public void publishWSDL(WSHTTPConnection connection) throws IOException;
/** Get URL pattern for this adapter */
public String getUrlPattern();
/** Check if adapter handles given URL pattern */
public boolean matches(String urlPattern);
}
/**
* HTTP connection abstraction for transport-agnostic processing
*/
public abstract class WSHTTPConnection {
/** Get HTTP request method */
public abstract String getRequestMethod();
/** Get request URI */
public abstract String getRequestURI();
/** Get request headers */
public abstract Map<String, List<String>> getRequestHeaders();
/** Get request header value */
public abstract String getRequestHeader(String name);
/** Get request input stream */
public abstract InputStream getInput() throws IOException;
/** Get response output stream */
public abstract OutputStream getOutput() throws IOException;
/** Set response status code */
public abstract void setStatus(int status);
/** Set response content type */
public abstract void setContentType(String contentType);
/** Set response header */
public abstract void setResponseHeader(String name, String value);
/** Set response headers */
public abstract void setResponseHeaders(Map<String, List<String>> headers);
/** Close connection */
public abstract void close() throws IOException;
/** Get query string */
public abstract String getQueryString();
/** Get path info */
public abstract String getPathInfo();
/** Check if connection is secure (HTTPS) */
public abstract boolean isSecure();
/** Get user principal */
public abstract Principal getUserPrincipal();
}Client-side HTTP transport for outbound web service calls.
/**
* HTTP client transport implementation
*/
package com.sun.xml.ws.transport.http.client;
public final class HttpTransportPipe extends AbstractTubeImpl {
/** Create HTTP transport pipe */
public static HttpTransportPipe create(ClientTubeAssemblerContext context);
/** Process outbound request */
public NextAction processRequest(Packet request);
/** Process inbound response */
public NextAction processResponse(Packet response);
/** Get supported content types */
public Set<String> getSupportedContentTypes();
}
/**
* HTTP client connection implementation
*/
public final class HttpClientTransport {
/** Create HTTP connection to endpoint */
public static HttpURLConnection createConnection(Packet request) throws IOException;
/** Configure connection with request properties */
public static void configureConnection(HttpURLConnection connection, Packet request);
/** Send request and receive response */
public static Packet sendRequest(HttpURLConnection connection, Packet request) throws IOException;
/** Handle HTTP authentication */
public static void handleAuthentication(HttpURLConnection connection, Packet request);
}Comprehensive servlet container integration supporting standard servlet deployment.
/**
* JAX-WS servlet for standard servlet container deployment
*/
package com.sun.xml.ws.transport.http.servlet;
public class WSServlet extends HttpServlet {
/** Initialize servlet with JAX-WS runtime */
public void init(ServletConfig servletConfig) throws ServletException;
/** Handle HTTP GET requests (WSDL publishing) */
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException;
/** Handle HTTP POST requests (SOAP messages) */
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException;
/** Handle HTTP PUT requests */
protected void doPut(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException;
/** Handle HTTP DELETE requests */
protected void doDelete(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException;
/** Destroy servlet and clean up resources */
public void destroy();
}
/**
* Servlet processing delegate for request handling
*/
public final class WSServletDelegate {
/** Create servlet delegate with configuration */
public static WSServletDelegate create(ServletContext servletContext) throws ServletException;
/** Register endpoint with URL pattern */
public void registerEndpoint(String urlPattern, WSEndpoint<?> endpoint);
/** Process servlet request */
public void doGet(HttpServletRequest request, HttpServletResponse response,
ServletContext servletContext) throws ServletException, IOException;
/** Process servlet request */
public void doPost(HttpServletRequest request, HttpServletResponse response,
ServletContext servletContext) throws ServletException, IOException;
/** Get registered endpoints */
public Map<String, WSEndpoint<?>> getEndpoints();
}Servlet-specific adapter implementation for bridging servlet requests to JAX-WS processing.
/**
* Servlet-specific adapter for handling servlet requests
*/
public final class ServletAdapter extends Adapter<WSHTTPConnection> {
/** Create servlet adapter */
public static ServletAdapter create(WSEndpoint<?> endpoint, ServletContext servletContext);
/** Handle servlet connection */
public void handle(WSHTTPConnection connection) throws IOException;
/** Get servlet context */
public ServletContext getServletContext();
/** Get valid document name */
public String getValidDocumentName(String documentName);
}
/**
* Servlet HTTP connection implementation
*/
public final class ServletConnectionImpl extends WSHTTPConnection {
/** Create servlet connection wrapper */
public ServletConnectionImpl(HttpServletRequest request, HttpServletResponse response);
/** Get HTTP request method */
public String getRequestMethod();
/** Get request URI */
public String getRequestURI();
/** Get servlet request */
public HttpServletRequest getRequest();
/** Get servlet response */
public HttpServletResponse getResponse();
}HTTP Service Provider Interface integration for pluggable HTTP server implementations.
/**
* HTTP SPI servlet implementation
*/
package com.sun.xml.ws.transport.httpspi.servlet;
public class WSSPIServlet extends HttpServlet {
/** Initialize SPI servlet */
public void init() throws ServletException;
/** Handle GET requests via SPI */
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException;
/** Handle POST requests via SPI */
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException;
}Servlet context listeners for lifecycle management and endpoint publishing.
/**
* Servlet context listener for JAX-WS endpoint lifecycle
*/
public final class WSServletContextListener implements ServletContextListener {
/** Initialize JAX-WS endpoints on context startup */
public void contextInitialized(ServletContextEvent event);
/** Destroy JAX-WS endpoints on context shutdown */
public void contextDestroyed(ServletContextEvent event);
/** Parse deployment descriptor */
public void parseDeploymentDescriptor(ServletContext context) throws ServletException;
}
/**
* Server-side servlet context listener
*/
package com.sun.xml.ws.server.servlet;
public final class WSServletContextListener implements ServletContextListener {
/** Context initialization with endpoint discovery */
public void contextInitialized(ServletContextEvent event);
/** Context destruction with cleanup */
public void contextDestroyed(ServletContextEvent event);
}Support for web.xml and JAX-WS deployment descriptor parsing.
/**
* Deployment descriptor parser for web service configuration
*/
public final class DeploymentDescriptorParser<A> {
/** Parse deployment descriptor */
public static List<SDDocumentSource> parse(
Container container,
ClassLoader classLoader,
ResourceLoader loader,
A adapter) throws MalformedURLException;
/** Parse sun-jaxws.xml deployment descriptor */
public static WSServletContextListener parseAdaptersAndCreateDelegate(
Container container,
ClassLoader classLoader,
ServletContext context) throws ServletException;
}Usage Examples:
import com.sun.xml.ws.transport.http.*;
import com.sun.xml.ws.transport.http.servlet.*;
// Standalone HTTP server
@WebService
public class CalculatorImpl {
@WebMethod
public int add(int a, int b) {
return a + b;
}
}
// Create and publish with HTTP adapter
WSEndpoint<CalculatorImpl> endpoint = WSEndpoint.create(
CalculatorImpl.class, true, null,
new QName("http://example.com/", "CalculatorService"),
new QName("http://example.com/", "CalculatorPort"),
Container.NONE,
BindingImpl.create(BindingID.SOAP11_HTTP),
null, null, null, true
);
HttpAdapter adapter = HttpAdapter.createAlone(endpoint, Collections.emptyMap());
// Custom HTTP connection handling
HttpEndpoint httpEndpoint = new HttpEndpoint(8080) {
protected void handle(WSHTTPConnection connection) throws IOException {
if ("GET".equals(connection.getRequestMethod())) {
adapter.publishWSDL(connection);
} else {
adapter.handle(connection);
}
}
};
// Servlet deployment (web.xml configuration)
/*
<servlet>
<servlet-name>WSServlet</servlet-name>
<servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>WSServlet</servlet-name>
<url-pattern>/calculator</url-pattern>
</servlet-mapping>
<listener>
<listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
</listener>
*/
// sun-jaxws.xml configuration
/*
<?xml version="1.0" encoding="UTF-8"?>
<endpoints xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime" version="2.0">
<endpoint name="calculator" implementation="com.example.CalculatorImpl" url-pattern="/calculator"/>
</endpoints>
*/
// Programmatic servlet adapter creation
ServletContext servletContext = getServletContext();
WSEndpoint<CalculatorImpl> endpoint = WSEndpoint.create(CalculatorImpl.class, true);
ServletAdapter servletAdapter = ServletAdapter.create(endpoint, servletContext);
// Custom servlet implementation
public class MyWSServlet extends WSServlet {
private WSServletDelegate delegate;
public void init(ServletConfig config) throws ServletException {
super.init(config);
delegate = WSServletDelegate.create(config.getServletContext());
// Register endpoints programmatically
WSEndpoint<?> endpoint = createEndpoint();
delegate.registerEndpoint("/myservice", endpoint);
}
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
delegate.doPost(req, resp, getServletContext());
}
}
// HTTP client transport configuration
Map<String, Object> requestContext = new HashMap<>();
requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://example.com/service");
requestContext.put("com.sun.xml.ws.connect.timeout", 30000);
requestContext.put("com.sun.xml.ws.request.timeout", 60000);
// Custom HTTP connection configuration
public class CustomHttpConnection extends WSHTTPConnection {
private HttpServletRequest request;
private HttpServletResponse response;
public CustomHttpConnection(HttpServletRequest req, HttpServletResponse resp) {
this.request = req;
this.response = resp;
}
public String getRequestMethod() {
return request.getMethod();
}
public void setStatus(int status) {
response.setStatus(status);
}
// Implement other abstract methods...
}Install with Tessl CLI
npx tessl i tessl/maven-com-sun-xml-ws--jaxws-rt