0
# Transport Integration
1
2
HTTP transport implementation and servlet container integration providing comprehensive support for various hosting scenarios including standalone HTTP servers, servlet containers, and application servers.
3
4
## Capabilities
5
6
### HTTP Transport
7
8
Core HTTP transport implementation providing direct HTTP server support and connection abstraction.
9
10
```java { .api }
11
/**
12
* HTTP-specific adapter for processing HTTP requests
13
*/
14
package com.sun.xml.ws.transport.http;
15
public final class HttpAdapter extends Adapter<WSHTTPConnection> {
16
/** Create standalone HTTP adapter */
17
public static HttpAdapter createAlone(WSEndpoint<?> endpoint, Map<String, String> urlPattern);
18
19
/** Create adapter with specified name */
20
public static HttpAdapter create(WSEndpoint<?> endpoint, Container container, String name);
21
22
/** Handle HTTP connection and process request */
23
public void handle(WSHTTPConnection connection) throws IOException;
24
25
/** Publish WSDL document for GET requests */
26
public void publishWSDL(WSHTTPConnection connection) throws IOException;
27
28
/** Get URL pattern for this adapter */
29
public String getUrlPattern();
30
31
/** Check if adapter handles given URL pattern */
32
public boolean matches(String urlPattern);
33
}
34
35
/**
36
* HTTP connection abstraction for transport-agnostic processing
37
*/
38
public abstract class WSHTTPConnection {
39
/** Get HTTP request method */
40
public abstract String getRequestMethod();
41
42
/** Get request URI */
43
public abstract String getRequestURI();
44
45
/** Get request headers */
46
public abstract Map<String, List<String>> getRequestHeaders();
47
48
/** Get request header value */
49
public abstract String getRequestHeader(String name);
50
51
/** Get request input stream */
52
public abstract InputStream getInput() throws IOException;
53
54
/** Get response output stream */
55
public abstract OutputStream getOutput() throws IOException;
56
57
/** Set response status code */
58
public abstract void setStatus(int status);
59
60
/** Set response content type */
61
public abstract void setContentType(String contentType);
62
63
/** Set response header */
64
public abstract void setResponseHeader(String name, String value);
65
66
/** Set response headers */
67
public abstract void setResponseHeaders(Map<String, List<String>> headers);
68
69
/** Close connection */
70
public abstract void close() throws IOException;
71
72
/** Get query string */
73
public abstract String getQueryString();
74
75
/** Get path info */
76
public abstract String getPathInfo();
77
78
/** Check if connection is secure (HTTPS) */
79
public abstract boolean isSecure();
80
81
/** Get user principal */
82
public abstract Principal getUserPrincipal();
83
}
84
```
85
86
### HTTP Client Transport
87
88
Client-side HTTP transport for outbound web service calls.
89
90
```java { .api }
91
/**
92
* HTTP client transport implementation
93
*/
94
package com.sun.xml.ws.transport.http.client;
95
public final class HttpTransportPipe extends AbstractTubeImpl {
96
/** Create HTTP transport pipe */
97
public static HttpTransportPipe create(ClientTubeAssemblerContext context);
98
99
/** Process outbound request */
100
public NextAction processRequest(Packet request);
101
102
/** Process inbound response */
103
public NextAction processResponse(Packet response);
104
105
/** Get supported content types */
106
public Set<String> getSupportedContentTypes();
107
}
108
109
/**
110
* HTTP client connection implementation
111
*/
112
public final class HttpClientTransport {
113
/** Create HTTP connection to endpoint */
114
public static HttpURLConnection createConnection(Packet request) throws IOException;
115
116
/** Configure connection with request properties */
117
public static void configureConnection(HttpURLConnection connection, Packet request);
118
119
/** Send request and receive response */
120
public static Packet sendRequest(HttpURLConnection connection, Packet request) throws IOException;
121
122
/** Handle HTTP authentication */
123
public static void handleAuthentication(HttpURLConnection connection, Packet request);
124
}
125
```
126
127
### Servlet Integration
128
129
Comprehensive servlet container integration supporting standard servlet deployment.
130
131
```java { .api }
132
/**
133
* JAX-WS servlet for standard servlet container deployment
134
*/
135
package com.sun.xml.ws.transport.http.servlet;
136
public class WSServlet extends HttpServlet {
137
/** Initialize servlet with JAX-WS runtime */
138
public void init(ServletConfig servletConfig) throws ServletException;
139
140
/** Handle HTTP GET requests (WSDL publishing) */
141
protected void doGet(HttpServletRequest request, HttpServletResponse response)
142
throws ServletException, IOException;
143
144
/** Handle HTTP POST requests (SOAP messages) */
145
protected void doPost(HttpServletRequest request, HttpServletResponse response)
146
throws ServletException, IOException;
147
148
/** Handle HTTP PUT requests */
149
protected void doPut(HttpServletRequest request, HttpServletResponse response)
150
throws ServletException, IOException;
151
152
/** Handle HTTP DELETE requests */
153
protected void doDelete(HttpServletRequest request, HttpServletResponse response)
154
throws ServletException, IOException;
155
156
/** Destroy servlet and clean up resources */
157
public void destroy();
158
}
159
160
/**
161
* Servlet processing delegate for request handling
162
*/
163
public final class WSServletDelegate {
164
/** Create servlet delegate with configuration */
165
public static WSServletDelegate create(ServletContext servletContext) throws ServletException;
166
167
/** Register endpoint with URL pattern */
168
public void registerEndpoint(String urlPattern, WSEndpoint<?> endpoint);
169
170
/** Process servlet request */
171
public void doGet(HttpServletRequest request, HttpServletResponse response,
172
ServletContext servletContext) throws ServletException, IOException;
173
174
/** Process servlet request */
175
public void doPost(HttpServletRequest request, HttpServletResponse response,
176
ServletContext servletContext) throws ServletException, IOException;
177
178
/** Get registered endpoints */
179
public Map<String, WSEndpoint<?>> getEndpoints();
180
}
181
```
182
183
### Servlet Container Adapter
184
185
Servlet-specific adapter implementation for bridging servlet requests to JAX-WS processing.
186
187
```java { .api }
188
/**
189
* Servlet-specific adapter for handling servlet requests
190
*/
191
public final class ServletAdapter extends Adapter<WSHTTPConnection> {
192
/** Create servlet adapter */
193
public static ServletAdapter create(WSEndpoint<?> endpoint, ServletContext servletContext);
194
195
/** Handle servlet connection */
196
public void handle(WSHTTPConnection connection) throws IOException;
197
198
/** Get servlet context */
199
public ServletContext getServletContext();
200
201
/** Get valid document name */
202
public String getValidDocumentName(String documentName);
203
}
204
205
/**
206
* Servlet HTTP connection implementation
207
*/
208
public final class ServletConnectionImpl extends WSHTTPConnection {
209
/** Create servlet connection wrapper */
210
public ServletConnectionImpl(HttpServletRequest request, HttpServletResponse response);
211
212
/** Get HTTP request method */
213
public String getRequestMethod();
214
215
/** Get request URI */
216
public String getRequestURI();
217
218
/** Get servlet request */
219
public HttpServletRequest getRequest();
220
221
/** Get servlet response */
222
public HttpServletResponse getResponse();
223
}
224
```
225
226
### HTTP SPI Integration
227
228
HTTP Service Provider Interface integration for pluggable HTTP server implementations.
229
230
```java { .api }
231
/**
232
* HTTP SPI servlet implementation
233
*/
234
package com.sun.xml.ws.transport.httpspi.servlet;
235
public class WSSPIServlet extends HttpServlet {
236
/** Initialize SPI servlet */
237
public void init() throws ServletException;
238
239
/** Handle GET requests via SPI */
240
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
241
throws ServletException, IOException;
242
243
/** Handle POST requests via SPI */
244
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
245
throws ServletException, IOException;
246
}
247
```
248
249
### Context Listeners
250
251
Servlet context listeners for lifecycle management and endpoint publishing.
252
253
```java { .api }
254
/**
255
* Servlet context listener for JAX-WS endpoint lifecycle
256
*/
257
public final class WSServletContextListener implements ServletContextListener {
258
/** Initialize JAX-WS endpoints on context startup */
259
public void contextInitialized(ServletContextEvent event);
260
261
/** Destroy JAX-WS endpoints on context shutdown */
262
public void contextDestroyed(ServletContextEvent event);
263
264
/** Parse deployment descriptor */
265
public void parseDeploymentDescriptor(ServletContext context) throws ServletException;
266
}
267
268
/**
269
* Server-side servlet context listener
270
*/
271
package com.sun.xml.ws.server.servlet;
272
public final class WSServletContextListener implements ServletContextListener {
273
/** Context initialization with endpoint discovery */
274
public void contextInitialized(ServletContextEvent event);
275
276
/** Context destruction with cleanup */
277
public void contextDestroyed(ServletContextEvent event);
278
}
279
```
280
281
### Deployment Descriptor Parsing
282
283
Support for web.xml and JAX-WS deployment descriptor parsing.
284
285
```java { .api }
286
/**
287
* Deployment descriptor parser for web service configuration
288
*/
289
public final class DeploymentDescriptorParser<A> {
290
/** Parse deployment descriptor */
291
public static List<SDDocumentSource> parse(
292
Container container,
293
ClassLoader classLoader,
294
ResourceLoader loader,
295
A adapter) throws MalformedURLException;
296
297
/** Parse sun-jaxws.xml deployment descriptor */
298
public static WSServletContextListener parseAdaptersAndCreateDelegate(
299
Container container,
300
ClassLoader classLoader,
301
ServletContext context) throws ServletException;
302
}
303
```
304
305
**Usage Examples:**
306
307
```java
308
import com.sun.xml.ws.transport.http.*;
309
import com.sun.xml.ws.transport.http.servlet.*;
310
311
// Standalone HTTP server
312
@WebService
313
public class CalculatorImpl {
314
@WebMethod
315
public int add(int a, int b) {
316
return a + b;
317
}
318
}
319
320
// Create and publish with HTTP adapter
321
WSEndpoint<CalculatorImpl> endpoint = WSEndpoint.create(
322
CalculatorImpl.class, true, null,
323
new QName("http://example.com/", "CalculatorService"),
324
new QName("http://example.com/", "CalculatorPort"),
325
Container.NONE,
326
BindingImpl.create(BindingID.SOAP11_HTTP),
327
null, null, null, true
328
);
329
330
HttpAdapter adapter = HttpAdapter.createAlone(endpoint, Collections.emptyMap());
331
332
// Custom HTTP connection handling
333
HttpEndpoint httpEndpoint = new HttpEndpoint(8080) {
334
protected void handle(WSHTTPConnection connection) throws IOException {
335
if ("GET".equals(connection.getRequestMethod())) {
336
adapter.publishWSDL(connection);
337
} else {
338
adapter.handle(connection);
339
}
340
}
341
};
342
343
// Servlet deployment (web.xml configuration)
344
/*
345
<servlet>
346
<servlet-name>WSServlet</servlet-name>
347
<servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
348
<load-on-startup>1</load-on-startup>
349
</servlet>
350
351
<servlet-mapping>
352
<servlet-name>WSServlet</servlet-name>
353
<url-pattern>/calculator</url-pattern>
354
</servlet-mapping>
355
356
<listener>
357
<listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
358
</listener>
359
*/
360
361
// sun-jaxws.xml configuration
362
/*
363
<?xml version="1.0" encoding="UTF-8"?>
364
<endpoints xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime" version="2.0">
365
<endpoint name="calculator" implementation="com.example.CalculatorImpl" url-pattern="/calculator"/>
366
</endpoints>
367
*/
368
369
// Programmatic servlet adapter creation
370
ServletContext servletContext = getServletContext();
371
WSEndpoint<CalculatorImpl> endpoint = WSEndpoint.create(CalculatorImpl.class, true);
372
ServletAdapter servletAdapter = ServletAdapter.create(endpoint, servletContext);
373
374
// Custom servlet implementation
375
public class MyWSServlet extends WSServlet {
376
private WSServletDelegate delegate;
377
378
public void init(ServletConfig config) throws ServletException {
379
super.init(config);
380
delegate = WSServletDelegate.create(config.getServletContext());
381
382
// Register endpoints programmatically
383
WSEndpoint<?> endpoint = createEndpoint();
384
delegate.registerEndpoint("/myservice", endpoint);
385
}
386
387
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
388
throws ServletException, IOException {
389
delegate.doPost(req, resp, getServletContext());
390
}
391
}
392
393
// HTTP client transport configuration
394
Map<String, Object> requestContext = new HashMap<>();
395
requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://example.com/service");
396
requestContext.put("com.sun.xml.ws.connect.timeout", 30000);
397
requestContext.put("com.sun.xml.ws.request.timeout", 60000);
398
399
// Custom HTTP connection configuration
400
public class CustomHttpConnection extends WSHTTPConnection {
401
private HttpServletRequest request;
402
private HttpServletResponse response;
403
404
public CustomHttpConnection(HttpServletRequest req, HttpServletResponse resp) {
405
this.request = req;
406
this.response = resp;
407
}
408
409
public String getRequestMethod() {
410
return request.getMethod();
411
}
412
413
public void setStatus(int status) {
414
response.setStatus(status);
415
}
416
417
// Implement other abstract methods...
418
}
419
```