|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectwt.httpgw.HTTPServer
The HTTPServer class represents the server-side service interface for dispatching HTTP requests to their corresponding service methods. The HTTPGateway object forwards requests to this class, which in turn dispatches them to service methods identified in the URL path information.
This class understands the special serialization being performed by the request and response objects and hides this from the dispatched service methods. Its main method is processRequest. This method receives a HTTPRequest object as input and returns a HTTPResponse object. The URL path information is examined to determine the actual target class and method. The target method is overloaded with two versions, one for handling posted request body content from an input stream, and another for generating the response to an output stream. These operations must be separate because the posted input stream is only available while deserializing the request object, and the response output stream is only available while serializing the response object.
A new HTTPResponse object is constructed and the target class and method is stored in this object. Response generation is deferred until serialization of the response object is underway so that the RMI marshal stream is available as a pipe to receive the generated response body.
For HTTP POST requests, the input-processing version of the target
method is invoked during request unmarshaling. If reflection cannot
find the input-processing version of the target method and the content
is URL encoded form data, the form data is parsed and stored on the
request object. This form data can then be retrieved later during
result writing using the getFromData
method on the
request object.
Application Developers View
Application developers expose functionality to HTTP clients by implementing methods that can be called by this HTTPServer class. These are simply methods with a specific signature that can be invoked using Java reflection. The only tricky part is that input stream processing and response generation are separated into two separate methods.
For example, if the Windchill HTTP gateway URL is
Then the following URL could be used to invoke the myAction method of the MyHTTPService class:http://www.wt.myco.com/servlet/windchill
The MyHTTPService class would contain myAction methods with the following signatures:http://www.wt.myco.com/servlet/windchill/MyHTTPService/myAction
The first form of the method is optional, only being required if the request is a POST type, there is a content-body, and the content-body is expected to be something other than URL encoded form data.Class MyHTTPService { void myAction (HTTPRequest req, HTTPResponse resp, InputStream is) { // Handle posted data // Free to set response attributes, // but don't try to get the output stream } void myAction (HTTPRequest req, HTTPResponse resp) { // Set response attributes // Generate response body // Free to get the output stream and write directly } }
Field Summary | |
private static boolean |
ACCESS_LOG_ENABLED
|
private static String |
ANONYMOUS_USER
|
private static String |
CONFIRM_AUTH_KEY
|
private static String |
HOMEPAGE_CLASS
|
private static String |
HOMEPAGE_METHOD
|
private static String |
HTTP_REQUEST_KEY
|
private static String |
POST_DATA_KEY
|
private static String |
QUERYSTR_KEY
|
private static String |
RESOURCE
|
private static boolean |
SHOW_TARGET
|
private static boolean |
VERBOSE
|
private static String |
WWW_AUTHENTICATE
|
Fields inherited from interface wt.method.RemoteAccess |
versionID |
Constructor Summary | |
private |
HTTPServer()
|
Method Summary | |
static void |
echo(HTTPRequest request,
HTTPResponse response)
Echo request Supported API: false |
static HTTPRequest |
getHTTPRequest()
Get HTTPRequest associated with the current method context. |
private static Boolean |
getReauthFlag(SessionContext session)
|
protected static boolean |
handleAuthenticationException(HTTPRequest request,
HTTPResponse response)
Internal server-side method to handle authentication exceptions thrown during request or response processing. |
protected static void |
processRequest(HTTPRequest request,
HTTPResponse response)
Internal server-side method to process a HTTP request. |
static HTTPResponse |
processRequest(Integer gateway_id,
HTTPRequest request)
Client API to process a HTTP request. |
static void |
reauth(HTTPRequest request,
HTTPResponse response)
Reauthenticate user Supported API: false |
private static void |
setSession(HTTPRequest request)
Internal server-side method to associate the current request with a previous session. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final String RESOURCE
private static boolean VERBOSE
private static String HOMEPAGE_CLASS
private static String HOMEPAGE_METHOD
private static boolean SHOW_TARGET
private static String ANONYMOUS_USER
private static boolean ACCESS_LOG_ENABLED
private static String WWW_AUTHENTICATE
private static final String CONFIRM_AUTH_KEY
private static final String POST_DATA_KEY
private static final String HTTP_REQUEST_KEY
private static final String QUERYSTR_KEY
Constructor Detail |
private HTTPServer()
Method Detail |
public static HTTPResponse processRequest(Integer gateway_id, HTTPRequest request) throws Throwable
Note that the response object is available from the start to
allow the target method to set HTTP response headers that will
get written when the response object's getOutputStream method is called.
Supported API: false
Throwable
protected static void processRequest(HTTPRequest request, HTTPResponse response)
private static void setSession(HTTPRequest request)
protected static boolean handleAuthenticationException(HTTPRequest request, HTTPResponse response)
private static Boolean getReauthFlag(SessionContext session)
public static HTTPRequest getHTTPRequest()
public static void echo(HTTPRequest request, HTTPResponse response) throws IOException
IOException
public static void reauth(HTTPRequest request, HTTPResponse response) throws IOException
IOException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |