com.sun.xml.ws.transport.http
Class WSHTTPConnection

java.lang.Object
  extended by com.oracle.webservices.api.message.BasePropertySet
      extended by com.sun.xml.ws.transport.http.WSHTTPConnection
All Implemented Interfaces:
com.oracle.webservices.api.message.PropertySet
Direct Known Subclasses:
ServletConnectionImpl

public abstract class WSHTTPConnection
extends com.oracle.webservices.api.message.BasePropertySet

The view of an HTTP exchange from the point of view of JAX-WS.

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).)


Nested Class Summary
 
Nested classes/interfaces inherited from class com.oracle.webservices.api.message.BasePropertySet
com.oracle.webservices.api.message.BasePropertySet.Accessor, com.oracle.webservices.api.message.BasePropertySet.PropertyMap, com.oracle.webservices.api.message.BasePropertySet.PropertyMapEntry
 
Nested classes/interfaces inherited from interface com.oracle.webservices.api.message.PropertySet
com.oracle.webservices.api.message.PropertySet.Property
 
Field Summary
static int INTERNAL_ERR
           
static int MALFORMED_XML
           
static int OK
           
static int ONEWAY
           
static int UNSUPPORTED_MEDIA
           
 
Constructor Summary
WSHTTPConnection()
           
 
Method Summary
 void close()
          Close the connection
 java.lang.String getBaseAddress()
          Gets the absolute URL up to the context path.
 java.lang.Object getContext()
          Environment specific context , if available
 java.lang.String getContextPath()
          Portion of the request URI that groups related service addresses.
 java.lang.String getCookie(java.lang.String name)
          Subclasses are expected to override
abstract  java.io.InputStream getInput()
          Transport's underlying input stream.
abstract  java.io.OutputStream getOutput()
          Transport's underlying output stream
abstract  java.lang.String getPathInfo()
          Extra portion of the request URI after the end of the expected address of the service but before the query string
 java.lang.String getProtocol()
          Subclasses are expected to override
abstract  java.lang.String getQueryString()
          HTTP Query string, such as "foo=bar", or null if none exists.
 java.lang.Object getRequestAttribute(java.lang.String key)
          Gets request metadata attribute
abstract  java.lang.String getRequestHeader(java.lang.String headerName)
          Gets an HTTP request header.
abstract  java.util.Set<java.lang.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  java.util.Map<java.lang.String,java.util.List<java.lang.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  java.util.List<java.lang.String> getRequestHeaderValues(java.lang.String headerName)
          Gets an HTTP request header.
abstract  java.lang.String getRequestMethod()
          HTTP request method, such as "GET" or "POST".
abstract  java.lang.String getRequestScheme()
          Requested scheme, e.g.
abstract  java.lang.String getRequestURI()
          Requested path.
abstract  java.util.Map<java.lang.String,java.util.List<java.lang.String>> getResponseHeaders()
           
abstract  java.lang.String getServerName()
          Server name
abstract  int getServerPort()
          Server port
abstract  int getStatus()
          Gets the last value set by setStatus(int).
 java.security.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(java.lang.String role)
          Whether user associated with the request holds the given role
 void setContentLengthResponseHeader(int value)
          Subclasses are expected to override
abstract  void setContentTypeResponseHeader(java.lang.String value)
          Sets the "Content-Type" header.
 void setCookie(java.lang.String name, java.lang.String value)
          Subclasses are expected to override
abstract  void setResponseHeader(java.lang.String key, java.util.List<java.lang.String> value)
           
 void setResponseHeader(java.lang.String key, java.lang.String value)
           
abstract  void setResponseHeaders(java.util.Map<java.lang.String,java.util.List<java.lang.String>> headers)
          Overwrites all the HTTP response headers written thus far.
abstract  void setStatus(int status)
          Sets the HTTP response code like OK.
 
Methods inherited from class com.oracle.webservices.api.message.BasePropertySet
asMap, containsKey, createEntrySet, createMapView, createView, get, getPropertyMap, mapAllowsAdditionalProperties, parse, put, remove, supports
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OK

public static final int OK
See Also:
Constant Field Values

ONEWAY

public static final int ONEWAY
See Also:
Constant Field Values

UNSUPPORTED_MEDIA

public static final int UNSUPPORTED_MEDIA
See Also:
Constant Field Values

MALFORMED_XML

public static final int MALFORMED_XML
See Also:
Constant Field Values

INTERNAL_ERR

public static final int INTERNAL_ERR
See Also:
Constant Field Values
Constructor Detail

WSHTTPConnection

public WSHTTPConnection()
Method Detail

setResponseHeaders

public abstract void setResponseHeaders(@NotNull
                                        java.util.Map<java.lang.String,java.util.List<java.lang.String>> headers)
Overwrites all the HTTP response headers written thus far.

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.

Parameters:
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.
See Also:
setContentTypeResponseHeader(String)

setResponseHeader

public void setResponseHeader(java.lang.String key,
                              java.lang.String value)

setResponseHeader

public abstract void setResponseHeader(java.lang.String key,
                                       java.util.List<java.lang.String> value)

setContentTypeResponseHeader

public abstract void setContentTypeResponseHeader(@NotNull
                                                  java.lang.String value)
Sets the "Content-Type" header.

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(java.util.Map) may be invoked in any arbitrary order.

Parameters:
value - strings like "application/xml; charset=UTF-8" or "image/jpeg".

setStatus

public abstract void setStatus(int status)
Sets the HTTP response code like 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.


getStatus

public abstract int getStatus()
Gets the last value set by setStatus(int).

Returns:
if setStatus(int) has not been invoked yet, return 0.

getInput

@NotNull
public abstract java.io.InputStream getInput()
                                      throws java.io.IOException
Transport's underlying input stream.

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.

Returns:
the stream from which the request body will be read.
Throws:
java.io.IOException

getOutput

@NotNull
public abstract java.io.OutputStream getOutput()
                                        throws java.io.IOException
Transport's underlying output stream

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>), and setContentTypeResponseHeader(String) will never be invoked.

Throws:
java.io.IOException

getWebServiceContextDelegate

@NotNull
public abstract WebServiceContextDelegate getWebServiceContextDelegate()
Returns the WebServiceContextDelegate for this connection.


getRequestMethod

@NotNull
public abstract java.lang.String getRequestMethod()
HTTP request method, such as "GET" or "POST".


getRequestHeaders

@NotNull
public abstract java.util.Map<java.lang.String,java.util.List<java.lang.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).

HTTP request headers.

Returns:
can be empty but never null.

getRequestHeaderNames

@NotNull
public abstract java.util.Set<java.lang.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).

HTTP request header names.

Returns:
can be empty but never null.

getResponseHeaders

public abstract java.util.Map<java.lang.String,java.util.List<java.lang.String>> getResponseHeaders()
Returns:
HTTP response headers.

getRequestHeader

@Nullable
public abstract java.lang.String getRequestHeader(@NotNull
                                                           java.lang.String headerName)
Gets an HTTP request header.

if multiple headers are present, this method returns one of them. (The implementation is free to choose which one it returns.)

Returns:
null if no header exists.

getRequestHeaderValues

@Nullable
public abstract java.util.List<java.lang.String> getRequestHeaderValues(@NotNull
                                                                                 java.lang.String headerName)
Gets an HTTP request header.

Returns:
null if no header exists.

getQueryString

@Nullable
public abstract java.lang.String getQueryString()
HTTP Query string, such as "foo=bar", or null if none exists.


getPathInfo

@Nullable
public abstract java.lang.String getPathInfo()
Extra portion of the request URI after the end of the expected address of the service but before the query string


getRequestURI

@NotNull
public abstract java.lang.String getRequestURI()
Requested path. A string like "/foo/bar/baz"


getRequestScheme

@NotNull
public abstract java.lang.String getRequestScheme()
Requested scheme, e.g. "http" or "https"


getServerName

@NotNull
public abstract java.lang.String getServerName()
Server name


getServerPort

public abstract int getServerPort()
Server port


getContextPath

@NotNull
public java.lang.String getContextPath()
Portion of the request URI that groups related service addresses. The value, if non-empty, will always begin with '/', but will never end with '/'. Environments that do not support context paths must return an empty string.


getContext

public java.lang.Object getContext()
Environment specific context , if available


getBaseAddress

@NotNull
public java.lang.String getBaseAddress()
Gets the absolute URL up to the context path.

Returns:
String like "http://myhost/myapp"
Since:
2.1.2

isSecure

public abstract boolean isSecure()
Whether connection is HTTPS or not

Returns:
if the received request is on HTTPS, return true else false

getUserPrincipal

public java.security.Principal getUserPrincipal()
User principal associated with the request

Returns:
user principal

isUserInRole

public boolean isUserInRole(java.lang.String role)
Whether user associated with the request holds the given role

Parameters:
role - Role to check
Returns:
if the caller holds the role

getRequestAttribute

public java.lang.Object getRequestAttribute(java.lang.String key)
Gets request metadata attribute

Parameters:
key - Request metadata key
Returns:
Value of metadata attribute or null, if no value present

close

public void close()
Close the connection


isClosed

public boolean isClosed()
Retuns whether connection is closed or not.


getProtocol

public java.lang.String getProtocol()
Subclasses are expected to override

Returns:
a String containing the protocol name and version number

getCookie

public java.lang.String getCookie(java.lang.String name)
Subclasses are expected to override

Returns:
value of given cookie
Since:
JAX-WS RI 2.2.2

setCookie

public void setCookie(java.lang.String name,
                      java.lang.String value)
Subclasses are expected to override

Since:
JAX-WS RI 2.2.2

setContentLengthResponseHeader

public void setContentLengthResponseHeader(int value)
Subclasses are expected to override



Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved.