Package org.httprpc

Class WebServiceProxy


  • public class WebServiceProxy
    extends java.lang.Object
    Web service proxy class.
    • Constructor Detail

      • WebServiceProxy

        public WebServiceProxy​(java.lang.String method,
                               java.net.URL url)
        Constructs a new web service proxy.
        Parameters:
        method - The HTTP method.
        url - The resource URL.
    • 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 null if 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, or null for no body.
        Returns:
        The web service proxy.
      • getRequestHandler

        public WebServiceProxy.RequestHandler getRequestHandler()
        Returns the request handler.
        Returns:
        The request handler, or null if no request handler has been set.
      • setRequestHandler

        public WebServiceProxy setRequestHandler​(WebServiceProxy.RequestHandler requestHandler)
        Sets the request handler.
        Parameters:
        requestHandler - The request handler, or null for the default request handler.
        Returns:
        The web service proxy.
      • getErrorHandler

        public WebServiceProxy.ErrorHandler getErrorHandler()
        Returns the error handler.
        Returns:
        The error handler, or null if no error handler has been set.
      • setErrorHandler

        public WebServiceProxy setErrorHandler​(WebServiceProxy.ErrorHandler errorHandler)
        Sets the error handler.
        Parameters:
        errorHandler - The error handler, or null for 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.IOException
        Invokes 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.IOException
        Invokes 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.