Package org.httprpc
Class WebServiceProxy
- java.lang.Object
-
- org.httprpc.WebServiceProxy
-
public class WebServiceProxy extends java.lang.ObjectWeb service proxy class.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWebServiceProxy.EncodingEncoding options for POST requests.static interfaceWebServiceProxy.ErrorHandlerInterface representing an error handler.static interfaceWebServiceProxy.RequestHandlerInterface representing a request handler.static interfaceWebServiceProxy.ResponseHandler<T>Interface representing a response handler.static classWebServiceProxy.StatusSuccess status values.
-
Constructor Summary
Constructors Constructor Description WebServiceProxy(java.lang.String method, java.net.URL url)Constructs a new web service proxy.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static WebServiceProxydelete(java.net.URL url)Creates a web service proxy representing a DELETE request.static WebServiceProxydelete(java.net.URL baseURL, java.lang.String path, java.lang.Object... args)Creates a web service proxy representing a DELETE request.static WebServiceProxyget(java.net.URL url)Creates a web service proxy representing a GET request.static WebServiceProxyget(java.net.URL baseURL, java.lang.String path, java.lang.Object... args)Creates a web service proxy representing a GET request.java.util.Map<java.lang.String,?>getArguments()Returns the argument map.java.lang.ObjectgetBody()Returns the request body.intgetConnectTimeout()Returns the connect timeout.WebServiceProxy.EncodinggetEncoding()Returns the encoding used for POST requests.WebServiceProxy.ErrorHandlergetErrorHandler()Returns the error handler.WebServiceProxy.StatusgetExpectedStatus()Returns the expected status.java.util.Map<java.lang.String,?>getHeaders()Returns the header map.java.lang.StringgetMethod()Returns the HTTP method.intgetReadTimeout()Returns the read timeout.WebServiceProxy.RequestHandlergetRequestHandler()Returns the request handler.java.net.URLgetURL()Returns the resource URL.<T> Tinvoke()Invokes the service operation.<T> Tinvoke(java.lang.reflect.Type type)Invokes the service operation.<T> Tinvoke(WebServiceProxy.ResponseHandler<? extends T> responseHandler)Invokes the service operation.static WebServiceProxypost(java.net.URL url)Creates a web service proxy representing a POST request.static WebServiceProxypost(java.net.URL baseURL, java.lang.String path, java.lang.Object... args)Creates a web service proxy representing a POST request.static WebServiceProxyput(java.net.URL url)Creates a web service proxy representing a PUT request.static WebServiceProxyput(java.net.URL baseURL, java.lang.String path, java.lang.Object... args)Creates a web service proxy representing a PUT request.WebServiceProxysetArguments(java.util.Map<java.lang.String,?> arguments)Sets the argument map.WebServiceProxysetBody(java.lang.Object body)Sets the request body.WebServiceProxysetConnectTimeout(int connectTimeout)Sets the connect timeout.WebServiceProxysetEncoding(WebServiceProxy.Encoding encoding)Sets the encoding used for POST requests.WebServiceProxysetErrorHandler(WebServiceProxy.ErrorHandler errorHandler)Sets the error handler.WebServiceProxysetExpectedStatus(WebServiceProxy.Status expectedStatus)Sets the expected status.WebServiceProxysetHeaders(java.util.Map<java.lang.String,?> headers)Sets the header map.WebServiceProxysetReadTimeout(int readTimeout)Sets the read timeout.WebServiceProxysetRequestHandler(WebServiceProxy.RequestHandler requestHandler)Sets the request handler.
-
-
-
Method Detail
-
getMethod
public java.lang.String getMethod()
Returns the HTTP method.- Returns:
- The HTTP method.
-
getURL
public java.net.URL getURL()
Returns the resource URL.- Returns:
- The resource URL.
-
getEncoding
public WebServiceProxy.Encoding getEncoding()
Returns the encoding used for POST requests.- Returns:
- The encoding used for POST requests.
-
setEncoding
public WebServiceProxy setEncoding(WebServiceProxy.Encoding encoding)
Sets the encoding used for POST requests.- Parameters:
encoding- The encoding used for POST requests.- Returns:
- The web service proxy.
-
getHeaders
public java.util.Map<java.lang.String,?> getHeaders()
Returns the header map.- Returns:
- The header map.
-
setHeaders
public WebServiceProxy setHeaders(java.util.Map<java.lang.String,?> headers)
Sets the header map.- Parameters:
headers- The header map.- Returns:
- The web service proxy.
-
getArguments
public java.util.Map<java.lang.String,?> getArguments()
Returns the argument map.- Returns:
- The argument map.
-
setArguments
public WebServiceProxy setArguments(java.util.Map<java.lang.String,?> arguments)
Sets the argument map.- Parameters:
arguments- The argument map.- Returns:
- The web service proxy.
-
getBody
public java.lang.Object getBody()
Returns the request body.- Returns:
- A value representing the body content, or
nullif no body has been set.
-
setBody
public WebServiceProxy setBody(java.lang.Object body)
Sets the request body.- Parameters:
body- A value representing the body content, ornullfor no body.- Returns:
- The web service proxy.
-
getRequestHandler
public WebServiceProxy.RequestHandler getRequestHandler()
Returns the request handler.- Returns:
- The request handler, or
nullif no request handler has been set.
-
setRequestHandler
public WebServiceProxy setRequestHandler(WebServiceProxy.RequestHandler requestHandler)
Sets the request handler.- Parameters:
requestHandler- The request handler, ornullfor the default request handler.- Returns:
- The web service proxy.
-
getErrorHandler
public WebServiceProxy.ErrorHandler getErrorHandler()
Returns the error handler.- Returns:
- The error handler, or
nullif no error handler has been set.
-
setErrorHandler
public WebServiceProxy setErrorHandler(WebServiceProxy.ErrorHandler errorHandler)
Sets the error handler.- Parameters:
errorHandler- The error handler, ornullfor the default error handler.- Returns:
- The web service proxy.
-
getConnectTimeout
public int getConnectTimeout()
Returns the connect timeout.- Returns:
- The connect timeout.
-
setConnectTimeout
public WebServiceProxy setConnectTimeout(int connectTimeout)
Sets the connect timeout.- Parameters:
connectTimeout- The connect timeout.- Returns:
- The web service proxy.
-
getReadTimeout
public int getReadTimeout()
Returns the read timeout.- Returns:
- The read timeout.
-
setReadTimeout
public WebServiceProxy setReadTimeout(int readTimeout)
Sets the read timeout.- Parameters:
readTimeout- The read timeout.- Returns:
- The web service proxy.
-
getExpectedStatus
public WebServiceProxy.Status getExpectedStatus()
Returns the expected status.- Returns:
- The expected status.
-
setExpectedStatus
public WebServiceProxy setExpectedStatus(WebServiceProxy.Status expectedStatus)
Sets the expected status.- Parameters:
expectedStatus- The expected status.- Returns:
- The web service proxy.
-
invoke
public <T> T invoke() throws java.io.IOExceptionInvokes the service operation.- Type Parameters:
T- The result type.- Returns:
- The result of the operation.
- Throws:
java.io.IOException- If an exception occurs while executing the operation.
-
invoke
public <T> T invoke(java.lang.reflect.Type type) throws java.io.IOExceptionInvokes the service operation.- Type Parameters:
T- The result type.- Parameters:
type- The result type.- Returns:
- The result of the operation.
- Throws:
java.io.IOException- If an exception occurs while executing the operation.
-
invoke
public <T> T invoke(WebServiceProxy.ResponseHandler<? extends T> responseHandler) throws java.io.IOException
Invokes the service operation.- Type Parameters:
T- The result type.- Parameters:
responseHandler- The response handler.- Returns:
- The result of the operation.
- Throws:
java.io.IOException- If an exception occurs while executing the operation.
-
get
public static WebServiceProxy get(java.net.URL url)
Creates a web service proxy representing a GET request.- Parameters:
url- The resource URL.- Returns:
- The new web service proxy.
-
get
public static WebServiceProxy get(java.net.URL baseURL, java.lang.String path, java.lang.Object... args) throws java.net.MalformedURLException
Creates a web service proxy representing a GET request.- Parameters:
baseURL- The base URL.path- The path to the resource, relative to the base URL.args- Path format specifier arguments.- Returns:
- The new web service proxy.
- Throws:
java.net.MalformedURLException- If a URL cannot be constructed from the base URL and path.
-
post
public static WebServiceProxy post(java.net.URL url)
Creates a web service proxy representing a POST request.- Parameters:
url- The resource URL.- Returns:
- The new web service proxy.
-
post
public static WebServiceProxy post(java.net.URL baseURL, java.lang.String path, java.lang.Object... args) throws java.net.MalformedURLException
Creates a web service proxy representing a POST request.- Parameters:
baseURL- The base URL.path- The path to the resource, relative to the base URL.args- Path format specifier arguments.- Returns:
- The new web service proxy.
- Throws:
java.net.MalformedURLException- If a URL cannot be constructed from the base URL and path.
-
put
public static WebServiceProxy put(java.net.URL url)
Creates a web service proxy representing a PUT request.- Parameters:
url- The resource URL.- Returns:
- The new web service proxy.
-
put
public static WebServiceProxy put(java.net.URL baseURL, java.lang.String path, java.lang.Object... args) throws java.net.MalformedURLException
Creates a web service proxy representing a PUT request.- Parameters:
baseURL- The base URL.path- The path to the resource, relative to the base URL.args- Path format specifier arguments.- Returns:
- The new web service proxy.
- Throws:
java.net.MalformedURLException- If a URL cannot be constructed from the base URL and path.
-
delete
public static WebServiceProxy delete(java.net.URL url)
Creates a web service proxy representing a DELETE request.- Parameters:
url- The resource URL.- Returns:
- The new web service proxy.
-
delete
public static WebServiceProxy delete(java.net.URL baseURL, java.lang.String path, java.lang.Object... args) throws java.net.MalformedURLException
Creates a web service proxy representing a DELETE request.- Parameters:
baseURL- The base URL.path- The path to the resource, relative to the base URL.args- Path format specifier arguments.- Returns:
- The new web service proxy.
- Throws:
java.net.MalformedURLException- If a URL cannot be constructed from the base URL and path.
-
-