Jakarta XML Web Services (JAX-WS) runtime implementation providing comprehensive SOAP web service capabilities
—
Client-side APIs for consuming web services with support for dynamic proxies, dispatch clients, service interception, and advanced client-side configuration. These APIs provide comprehensive client-side web service functionality.
Client-side service interception providing extension points for customizing service behavior and proxy creation.
/**
* Client-side service interception for customizing web service behavior
*/
package com.sun.xml.ws.api.client;
public interface ServiceInterceptor {
/** Customize features before binding creation */
List<WebServiceFeature> preCreateBinding(WSPortInfo portInfo, List<WebServiceFeature> features);
/** Customize proxy after creation */
void postCreateProxy(WSBindingProvider bindingProvider, Class<?> serviceEndpointInterface);
}
/**
* Factory for service interceptors
*/
public abstract class ServiceInterceptorFactory {
/** Create interceptor for service */
public abstract ServiceInterceptor create(WSPortInfo portInfo);
/** Load interceptor factories via ServiceLoader */
public static List<ServiceInterceptorFactory> load();
}
/**
* Port information for service interception
*/
public interface WSPortInfo extends PortInfo {
/** Get endpoint address */
String getEndpointAddress();
/** Get WSDL service name */
QName getServiceName();
/** Get WSDL port name */
QName getPortName();
/** Get binding ID */
BindingID getBindingId();
/** Get port model */
WSDLPort getPort();
/** Get owner service */
WSService getOwner();
}Enhanced binding provider interface with JAX-WS RI specific extensions.
/**
* Extended binding provider with JAX-WS RI specific functionality
*/
package com.sun.xml.ws.developer;
public interface WSBindingProvider extends BindingProvider {
/** Set endpoint address */
void setAddress(String address);
/** Get WS-Addressing endpoint reference */
WSEndpointReference getWSEndpointReference();
/** Get port information */
WSPortInfo getPortInfo();
/** Get outbound headers for next request */
Headers getInboundHeaders();
/** Set outbound headers for next request */
void setOutboundHeaders(Headers headers);
/** Set outbound headers from Objects */
void setOutboundHeaders(Object... headers);
/** Set outbound headers from list */
void setOutboundHeaders(List<Header> headers);
/** Get inbound headers from last response */
Headers getInboundHeaders();
}Client-side configuration and context management.
/**
* Client request context implementation
*/
package com.sun.xml.ws.client;
public final class RequestContext extends BasePropertySet {
/** Create request context with fallback */
public RequestContext(MapContext fallback);
/** Get endpoint address */
public String getEndpointAddress();
/** Set endpoint address */
public void setEndpointAddress(String address);
/** Copy context */
public RequestContext copy();
/** Fill request packet with context properties */
public void fill(Packet packet, boolean isAddressingEnabled);
}
/**
* Client response context implementation
*/
public final class ResponseContext extends BasePropertySet {
/** Create response context from packet */
public ResponseContext(Packet packet);
/** Get HTTP response code */
public Integer getResponseCode();
/** Get response headers */
public Map<String, List<String>> getResponseHeaders();
}Client-side content negotiation for optimizing message formats.
/**
* Content negotiation for optimal encoding selection
*/
package com.sun.xml.ws.client;
public enum ContentNegotiation {
/** No content negotiation */
none,
/** Pessimistic negotiation - assume server doesn't support optimized encodings */
pessimistic,
/** Optimistic negotiation - assume server supports optimized encodings */
optimistic;
/** Get property name for configuration */
public static final String PROPERTY = "com.sun.xml.ws.client.ContentNegotiation";
}Type-safe dispatch client for dynamic web service invocation.
/**
* Enhanced dispatch implementation with JAX-WS RI extensions
*/
package com.sun.xml.ws.client.dispatch;
public abstract class DispatchImpl<T> implements Dispatch<T>, WSBindingProvider {
/** Get request context */
public Map<String, Object> getRequestContext();
/** Get response context */
public Map<String, Object> getResponseContext();
/** Get binding */
public Binding getBinding();
/** Invoke operation synchronously */
public abstract T invoke(T msg);
/** Invoke operation asynchronously with callback */
public abstract Future<?> invokeAsync(T msg, AsyncHandler<T> handler);
/** Invoke operation asynchronously */
public abstract Response<T> invokeAsync(T msg);
/** Invoke one-way operation */
public abstract void invokeOneWay(T msg);
}
/**
* Message-based dispatch for SOAP messages
*/
public final class MessageDispatch extends DispatchImpl<Message> {
/** Invoke with Message object */
public Message invoke(Message message);
/** Async invoke with Message */
public Future<?> invokeAsync(Message message, AsyncHandler<Message> handler);
/** One-way invoke with Message */
public void invokeOneWay(Message message);
}
/**
* Packet-based dispatch for low-level message processing
*/
public final class PacketDispatch extends DispatchImpl<Packet> {
/** Invoke with Packet object */
public Packet invoke(Packet packet);
/** Process packet through client pipeline */
public Packet process(Packet request);
}Client-side exception handling and completion features.
/**
* Feature for handling exceptions in packet completion
*/
public final class ThrowableInPacketCompletionFeature extends WebServiceFeature {
/** Feature ID */
public static final String ID = "com.sun.xml.ws.api.client.ThrowableInPacketCompletionFeature";
/** Default constructor enabling the feature */
public ThrowableInPacketCompletionFeature();
/** Constructor with enable/disable flag */
public ThrowableInPacketCompletionFeature(boolean enabled);
/** Get feature ID */
public String getID();
}Asynchronous processing support for client operations.
/**
* Asynchronous response context
*/
package com.sun.xml.ws.api.client;
public interface AsyncResponseContext {
/** Get response when available */
Response<?> getResponse();
/** Set response */
void setResponse(Response<?> response);
/** Check if response is available */
boolean isComplete();
}
/**
* Async provider interface for custom async handling
*/
public interface AsyncProvider<T> {
/** Process async request */
void invoke(T request, AsyncProviderCallback<T> callback, WebServiceContext context);
}Usage Examples:
import com.sun.xml.ws.api.client.*;
import com.sun.xml.ws.developer.*;
import com.sun.xml.ws.client.*;
// Service interception
public class MyServiceInterceptor implements ServiceInterceptor {
public List<WebServiceFeature> preCreateBinding(WSPortInfo portInfo, List<WebServiceFeature> features) {
// Add custom features
features.add(new StreamingAttachmentFeature());
return features;
}
public void postCreateProxy(WSBindingProvider bindingProvider, Class<?> serviceEndpointInterface) {
// Configure proxy
bindingProvider.getRequestContext().put(
BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
"http://new-endpoint.com/service"
);
}
}
// Register interceptor factory
public class MyServiceInterceptorFactory extends ServiceInterceptorFactory {
public ServiceInterceptor create(WSPortInfo portInfo) {
return new MyServiceInterceptor();
}
}
// Enhanced binding provider usage
MyService service = new MyService();
MyServiceInterface port = service.getMyServicePort();
WSBindingProvider wsBP = (WSBindingProvider) port;
// Set outbound headers
Header customHeader = Headers.create(new QName("http://example.com", "Auth"), "token123");
wsBP.setOutboundHeaders(customHeader);
// Configure endpoint
wsBP.setAddress("http://localhost:8080/myservice");
// Make call
String result = port.myOperation("input");
// Get inbound headers
Headers inboundHeaders = wsBP.getInboundHeaders();
Header responseHeader = inboundHeaders.get(new QName("http://example.com", "ResponseInfo"), false);
// Content negotiation
Map<String, Object> requestContext = ((BindingProvider) port).getRequestContext();
requestContext.put(ContentNegotiation.PROPERTY, ContentNegotiation.optimistic);
// Dispatch client usage
Service service = Service.create(wsdlURL, serviceName);
Dispatch<Message> dispatch = service.createDispatch(portName, Message.class, Service.Mode.MESSAGE);
// Configure dispatch
dispatch.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointAddress);
// Create message
Message requestMessage = Messages.create(jaxbContext, requestObject, SOAPVersion.SOAP_11);
// Synchronous invoke
Message responseMessage = dispatch.invoke(requestMessage);
// Asynchronous invoke
Future<Message> futureResponse = dispatch.invokeAsync(requestMessage);
Message response = futureResponse.get();
// With callback
dispatch.invokeAsync(requestMessage, new AsyncHandler<Message>() {
public void handleResponse(Response<Message> response) {
try {
Message result = response.get();
// Process result
} catch (Exception e) {
// Handle error
}
}
});Install with Tessl CLI
npx tessl i tessl/maven-com-sun-xml-ws--jaxws-rt