public abstract class WSHTTPConnection
extends org.jvnet.ws.message.BasePropertySet
Different HTTP server layer uses different implementations of this class so that JAX-WS can be shielded from individuality of such layers. This is an interface implemented as an abstract class, so that future versions of the JAX-WS RI can add new methods.
This class extends PropertySet
so that a transport can
expose its properties to the application and pipes. (This object
will be added to Packet.addSatellite(PropertySet)
.)
Modifier and Type | Field and Description |
---|---|
static int |
INTERNAL_ERR |
static int |
MALFORMED_XML |
static int |
OK |
static int |
ONEWAY |
static int |
UNSUPPORTED_MEDIA |
Constructor and Description |
---|
WSHTTPConnection() |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the connection
|
String |
getBaseAddress()
Gets the absolute URL up to the context path.
|
Object |
getContext()
Environment specific context , if available
|
String |
getContextPath()
Portion of the request URI that groups related service addresses.
|
String |
getCookie(String name)
Subclasses are expected to override
|
abstract InputStream |
getInput()
Transport's underlying input stream.
|
abstract OutputStream |
getOutput()
Transport's underlying output stream
|
abstract String |
getPathInfo()
Extra portion of the request URI after the end of the expected address of the service
but before the query string
|
String |
getProtocol()
Subclasses are expected to override
|
abstract String |
getQueryString()
HTTP Query string, such as "foo=bar", or null if none exists.
|
Object |
getRequestAttribute(String key)
Gets request metadata attribute
|
abstract String |
getRequestHeader(String headerName)
Gets an HTTP request header.
|
abstract Set<String> |
getRequestHeaderNames()
Deprecated.
This is a potentially expensive operation.
Programs that want to access HTTP headers should consider using
other methods such as
getRequestHeader(String) . |
abstract Map<String,List<String>> |
getRequestHeaders()
Deprecated.
This is a potentially expensive operation.
Programs that want to access HTTP headers should consider using
other methods such as
getRequestHeader(String) . |
abstract List<String> |
getRequestHeaderValues(String headerName)
Gets an HTTP request header.
|
abstract String |
getRequestMethod()
HTTP request method, such as "GET" or "POST".
|
abstract String |
getRequestScheme()
Requested scheme, e.g.
|
abstract String |
getRequestURI()
Requested path.
|
abstract Map<String,List<String>> |
getResponseHeaders() |
abstract String |
getServerName()
Server name
|
abstract int |
getServerPort()
Server port
|
abstract int |
getStatus()
Gets the last value set by
setStatus(int) . |
Principal |
getUserPrincipal()
User principal associated with the request
|
abstract WebServiceContextDelegate |
getWebServiceContextDelegate()
Returns the
WebServiceContextDelegate for this connection. |
boolean |
isClosed()
Retuns whether connection is closed or not.
|
abstract boolean |
isSecure()
Whether connection is HTTPS or not
|
boolean |
isUserInRole(String role)
Whether user associated with the request holds the given role
|
void |
setContentLengthResponseHeader(int value)
Subclasses are expected to override
|
abstract void |
setContentTypeResponseHeader(String value)
Sets the "Content-Type" header.
|
void |
setCookie(String name,
String value)
Subclasses are expected to override
|
abstract void |
setResponseHeader(String key,
List<String> value) |
void |
setResponseHeader(String key,
String value) |
abstract void |
setResponseHeaders(Map<String,List<String>> headers)
Overwrites all the HTTP response headers written thus far.
|
abstract void |
setStatus(int status)
Sets the HTTP response code like
OK . |
public static final int OK
public static final int ONEWAY
public static final int UNSUPPORTED_MEDIA
public static final int MALFORMED_XML
public static final int INTERNAL_ERR
public abstract void setResponseHeaders(@NotNull Map<String,List<String>> headers)
The implementation should copy the contents of the Map
,
rather than retaining a reference. The Map
passed as a
parameter may change after this method is invoked.
This method may be called repeatedly, although in normal use case that's rare (so the implementation is encourage to take advantage of this usage pattern to improve performance, if possible.)
Initially, no header is set.
This parameter is usually exposed to WebServiceContext
as Packet.OUTBOUND_TRANSPORT_HEADERS
, and thus it
should ignore Content-Type and Content-Length headers.
headers
- See URLConnection.getHeaderFields()
for the format.
This parameter may not be null, but since the user application
code may invoke this method, a graceful error checking with
an helpful error message should be provided if it's actually null.setContentTypeResponseHeader(String)
public abstract void setContentTypeResponseHeader(@NotNull String value)
If the Content-Type header has already been set, this method will overwrite the previously set value. If not, this method adds it.
Note that this method and #setResponseHeaders(Map<String,List<String>>)
may be invoked in any arbitrary order.
value
- strings like "application/xml; charset=UTF-8" or
"image/jpeg".public abstract void setStatus(int status)
OK
.
While JAX-WS processes a WSHTTPConnection
, it
will at least call this method once to set a valid HTTP response code.
Note that this method may be invoked multiple times (from user code),
so do not consider the value to be final until getOutput()
is invoked.
public abstract int getStatus()
setStatus(int)
.setStatus(int)
has not been invoked yet,
return 0.@NotNull public abstract InputStream getInput() throws IOException
This method will be invoked at most once by the JAX-WS RI to
read the request body. If there's no request body, this method
should return an empty InputStream
.
IOException
@NotNull public abstract OutputStream getOutput() throws IOException
This method will be invoked exactly once by the JAX-WS RI to start writing the response body (unless the processing aborts abnormally.) Even if there's no response body to write, this method will still be invoked only to be closed immediately.
Once this method is called, the status code and response
headers will never change (IOW setStatus(int)
,
setResponseHeaders(java.util.Map<java.lang.String, java.util.List<java.lang.String>>)
, and setContentTypeResponseHeader(String)
will never be invoked.
IOException
@NotNull public abstract WebServiceContextDelegate getWebServiceContextDelegate()
WebServiceContextDelegate
for this connection.@NotNull public abstract String getRequestMethod()
@NotNull public abstract Map<String,List<String>> getRequestHeaders()
getRequestHeader(String)
.@NotNull public abstract Set<String> getRequestHeaderNames()
getRequestHeader(String)
.public abstract Map<String,List<String>> getResponseHeaders()
@Nullable public abstract String getRequestHeader(@NotNull String headerName)
if multiple headers are present, this method returns one of them. (The implementation is free to choose which one it returns.)
@Nullable public abstract List<String> getRequestHeaderValues(@NotNull String headerName)
@Nullable public abstract String getQueryString()
@Nullable public abstract String getPathInfo()
@NotNull public abstract String getRequestURI()
@NotNull public abstract String getRequestScheme()
@NotNull public abstract String getServerName()
public abstract int getServerPort()
@NotNull public String getContextPath()
public Object getContext()
@NotNull public String getBaseAddress()
public abstract boolean isSecure()
public Principal getUserPrincipal()
public boolean isUserInRole(String role)
role
- Role to checkpublic Object getRequestAttribute(String key)
key
- Request metadata keypublic void close()
public boolean isClosed()
public String getProtocol()
public String getCookie(String name)
public void setCookie(String name, String value)
public void setContentLengthResponseHeader(int value)
Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved.