Top Description Fields Constructors Methods
javax.xml.ws.spi.http

public abstract Class HttpExchange

extends Object
Class Inheritance
Imports
javax.xml.ws.handler.MessageContext, java.io.InputStream, .OutputStream, .IOException, java.net.InetSocketAddress, java.util.List, .Map, .Set, java.security.Principal

This class encapsulates a HTTP request received and a response to be generated in one exchange. It provides methods for examining the request from the client, and for building and sending the response.

A HttpExchange must be closed to free or reuse underlying resources. The effect of failing to close an exchange is undefined.

Author
Jitendra Kotamraju
Since
1.7, JAX-WS 2.2

Field Summary

Modifier and TypeField and Description
public static final String
REQUEST_CIPHER_SUITE

Standard property: cipher suite value when the request is received over HTTPS

Type: String

public static final String
REQUEST_KEY_SIZE

Standard property: bit size of the algorithm when the request is received over HTTPS

Type: Integer

public static final String
REQUEST_X509CERTIFICATE

Standard property: A SSL certificate, if any, associated with the request

Type: java.security.cert.X509Certificate[] The order of this array is defined as being in ascending order of trust.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public abstract void
addResponseHeader(String
the name of the header
name
,
String
the additional header value. If it contains octet string, it should be encoded according to RFC 2047 (http://www.ietf.org/rfc/rfc2047.txt)
value
)

Adds a response header with the given name and value.

public abstract void
close()

This must be called to end an exchange.

public abstract Object

Returns:

the attribute value, or null if the attribute doesn't exist
getAttribute
(String
attribute name
name
)

Returns an attribute that is associated with this HttpExchange.

public abstract Set<String>

Returns:

set of all attribute names
getAttributeNames
()

Gives all the attribute names that are associated with this HttpExchange.

public abstract String

Returns:

context path of all the endpoints in an application
getContextPath
()

Returns the context path of all the endpoints in an application.

public abstract HttpContext

Returns:

the HttpContext for this exchange
getHttpContext
()

Returns a HttpContext for this exchange.

public abstract InetSocketAddress

Returns:

the InetSocketAddress of the local interface
getLocalAddress
()

Returns the unresolved local address on which the request was received.

public abstract String

Returns:

decoded extra path information of web service. It is the path that comes after the web service path but before the query string in the request URI null if there is no extra path in the request URI
getPathInfo
()

Returns the extra path information that follows the web service path but precedes the query string in the request URI and will start with a "/" character.

public abstract String

Returns:

the protocol string from the request
getProtocol
()

Returns the protocol string from the request in the form protocol/majorVersion.minorVersion.

public abstract String

Returns:

undecoded query string of request URI, or null if the request URI doesn't have one
getQueryString
()

Returns the query string that is contained in the request URI after the path.

public abstract InetSocketAddress

Returns:

the InetSocketAddress of the caller
getRemoteAddress
()

Returns the unresolved address of the remote entity invoking this request.

public abstract InputStream

Returns:

the stream from which the request body can be read.
getRequestBody
()

Returns a stream from which the request body can be read.

public abstract String

Returns:

returns the value of the requested header, or null if the request does not have a header of that name
getRequestHeader
(String
the name of the request header
name
)

Returns the value of the specified request header.

public abstract Map<String, List<String>>

Returns:

an immutable Map which can be used to access request headers
getRequestHeaders
()

Returns an immutable Map containing the HTTP headers that were included with this request.

public abstract String

Returns:

the request method
getRequestMethod
()

Get the HTTP request method

public abstract String

Returns:

the request URI
getRequestURI
()

Returns the part of the request's URI from the protocol name up to the query string in the first line of the HTTP request.

public abstract OutputStream

Returns:

the stream to which the response body is written
getResponseBody
()

Returns a stream to which the response body must be written.

public abstract Map<String, List<String>>

Returns:

a mutable Map which can be used to set response headers.
getResponseHeaders
()

Returns a mutable Map into which the HTTP response headers can be stored and which will be transmitted as part of this response.

public abstract String

Returns:

name of the scheme used to make this request
getScheme
()

Returns the name of the scheme used to make this request, for example: http, or https.

public abstract Principal

Returns:

Principal for an authenticated user, or null if not authenticated
getUserPrincipal
()

Returns the Principal that represents the authenticated user for this HttpExchange.

public abstract boolean

Returns:

true if the user making this request belongs to a given role
isUserInRole
(String
specifies the name of the role
role
)

Indicates whether an authenticated user is included in the specified logical "role".

public abstract void
setStatus(int
the response code to send
status
)

Sets the HTTP status code for the response.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

REQUEST_CIPHER_SUITEback to summary
public static final String REQUEST_CIPHER_SUITE

Standard property: cipher suite value when the request is received over HTTPS

Type: String

REQUEST_KEY_SIZEback to summary
public static final String REQUEST_KEY_SIZE

Standard property: bit size of the algorithm when the request is received over HTTPS

Type: Integer

REQUEST_X509CERTIFICATEback to summary
public static final String REQUEST_X509CERTIFICATE

Standard property: A SSL certificate, if any, associated with the request

Type: java.security.cert.X509Certificate[] The order of this array is defined as being in ascending order of trust. The first certificate in the chain is the one set by the client, the next is the one used to authenticate the first, and so on.

Constructor Detail

HttpExchangeback to summary
public HttpExchange()

Method Detail

addResponseHeaderback to summary
public abstract void addResponseHeader(String name, String value)

Adds a response header with the given name and value. This method allows a response header to have multiple values. This is a convenience method to add a response header(instead of using the getResponseHeaders()).

Parameters
name:String

the name of the header

value:String

the additional header value. If it contains octet string, it should be encoded according to RFC 2047 (http://www.ietf.org/rfc/rfc2047.txt)

See Also
getResponseHeaders
closeback to summary
public abstract void close() throws IOException

This must be called to end an exchange. Container takes care of closing request and response streams. This must be called so that the container can free or reuse underlying resources.

Exceptions
IOException:
if any i/o error
getAttributeback to summary
public abstract Object getAttribute(String name)

Returns an attribute that is associated with this HttpExchange. JAX-WS handlers and endpoints may then access the attribute via MessageContext.

Servlet containers must expose MessageContext#SERVLET_CONTEXT, MessageContext#SERVLET_REQUEST, and MessageContext#SERVLET_RESPONSE as attributes.

If the request has been received by the container using HTTPS, the following information must be exposed as attributes. These attributes are REQUEST_CIPHER_SUITE, and REQUEST_KEY_SIZE. If there is a SSL certificate associated with the request, it must be exposed using REQUEST_X509CERTIFICATE

Parameters
name:String

attribute name

Returns:Object

the attribute value, or null if the attribute doesn't exist

getAttributeNamesback to summary
public abstract Set<String> getAttributeNames()

Gives all the attribute names that are associated with this HttpExchange.

Returns:Set<String>

set of all attribute names

See Also
getAttribute(String)
getContextPathback to summary
public abstract String getContextPath()

Returns the context path of all the endpoints in an application. This path is the portion of the request URI that indicates the context of the request. The context path always comes first in a request URI. The path starts with a "/" character but does not end with a "/" character. If this method returns "", the request is for default context. The container does not decode this string.

Context path is used in computing the endpoint address. See HttpContext#getPath

Returns:String

context path of all the endpoints in an application

See Also
HttpContext#getPath
getHttpContextback to summary
public abstract HttpContext getHttpContext()

Returns a HttpContext for this exchange. Container matches the request with the associated Endpoint's HttpContext

Returns:HttpContext

the HttpContext for this exchange

getLocalAddressback to summary
public abstract InetSocketAddress getLocalAddress()

Returns the unresolved local address on which the request was received.

Returns:InetSocketAddress

the InetSocketAddress of the local interface

getPathInfoback to summary
public abstract String getPathInfo()

Returns the extra path information that follows the web service path but precedes the query string in the request URI and will start with a "/" character.

This can be used for MessageContext#PATH_INFO

Returns:String

decoded extra path information of web service. It is the path that comes after the web service path but before the query string in the request URI null if there is no extra path in the request URI

getProtocolback to summary
public abstract String getProtocol()

Returns the protocol string from the request in the form protocol/majorVersion.minorVersion. For example, "HTTP/1.1"

Returns:String

the protocol string from the request

getQueryStringback to summary
public abstract String getQueryString()

Returns the query string that is contained in the request URI after the path.

This can be used for MessageContext#QUERY_STRING

Returns:String

undecoded query string of request URI, or null if the request URI doesn't have one

getRemoteAddressback to summary
public abstract InetSocketAddress getRemoteAddress()

Returns the unresolved address of the remote entity invoking this request.

Returns:InetSocketAddress

the InetSocketAddress of the caller

getRequestBodyback to summary
public abstract InputStream getRequestBody() throws IOException

Returns a stream from which the request body can be read. Multiple calls to this method will return the same stream.

Returns:InputStream

the stream from which the request body can be read.

Exceptions
IOException:
if any i/o error during request processing
getRequestHeaderback to summary
public abstract String getRequestHeader(String name)

Returns the value of the specified request header. If the request did not include a header of the specified name, this method returns null. If there are multiple headers with the same name, this method returns the first header in the request. The header name is case-insensitive. This is a convienence method to get a header (instead of using the getRequestHeaders).

Parameters
name:String

the name of the request header

Returns:String

returns the value of the requested header, or null if the request does not have a header of that name

getRequestHeadersback to summary
public abstract Map<String, List<String>> getRequestHeaders()

Returns an immutable Map containing the HTTP headers that were included with this request. The keys in this Map will be the header names, while the values will be a List of Strings containing each value that was included (either for a header that was listed several times, or one that accepts a comma-delimited list of values on a single line). In either of these cases, the values for the header name will be presented in the order that they were included in the request.

The keys in Map are case-insensitive.

Returns:Map<String, List<String>>

an immutable Map which can be used to access request headers

getRequestMethodback to summary
public abstract String getRequestMethod()

Get the HTTP request method

Returns:String

the request method

getRequestURIback to summary
public abstract String getRequestURI()

Returns the part of the request's URI from the protocol name up to the query string in the first line of the HTTP request. Container doesn't decode this string.

Returns:String

the request URI

getResponseBodyback to summary
public abstract OutputStream getResponseBody() throws IOException

Returns a stream to which the response body must be written. setStatus) must be called prior to calling this method. Multiple calls to this method (for the same exchange) will return the same stream.

Returns:OutputStream

the stream to which the response body is written

Exceptions
IOException:
if any i/o error during response processing
getResponseHeadersback to summary
public abstract Map<String, List<String>> getResponseHeaders()

Returns a mutable Map into which the HTTP response headers can be stored and which will be transmitted as part of this response. The keys in the Map will be the header names, while the values must be a List of Strings containing each value that should be included multiple times (in the order that they should be included).

The keys in Map are case-insensitive.

Returns:Map<String, List<String>>

a mutable Map which can be used to set response headers.

getSchemeback to summary
public abstract String getScheme()

Returns the name of the scheme used to make this request, for example: http, or https.

Returns:String

name of the scheme used to make this request

getUserPrincipalback to summary
public abstract Principal getUserPrincipal()

Returns the Principal that represents the authenticated user for this HttpExchange.

Returns:Principal

Principal for an authenticated user, or null if not authenticated

isUserInRoleback to summary
public abstract boolean isUserInRole(String role)

Indicates whether an authenticated user is included in the specified logical "role".

Parameters
role:String

specifies the name of the role

Returns:boolean

true if the user making this request belongs to a given role

setStatusback to summary
public abstract void setStatus(int status)

Sets the HTTP status code for the response.

This method must be called prior to calling getResponseBody.

Parameters
status:int

the response code to send

See Also
getResponseBody