org.sr.client
Class JSONRRClient

java.lang.Object
  extended by org.sr.client.JSONRRClient

public class JSONRRClient
extends java.lang.Object

This is java client class of simple remoting. Class contains methods to access remote services.Class supports authentication with BASIC,DIGEST & NTLM methods.
Usage:
JSONClient client = new JSONRRClient("http://localhost:8080/sr/JSONRR");
JSONResponse resp = client.callAService("echoBean","echo", null, "test");

Author:
Serhat Dirik
See Also:
TSAuthenticator

Constructor Summary
JSONRRClient(java.lang.String jsonRRServletURL)
          Client constructor for http connections to call service anonymously
JSONRRClient(java.lang.String jsonRRServletURL, java.lang.String userName, java.lang.String password)
          Client constructor for http connections to call services with the given security credentials
JSONRRClient(java.lang.String jsonRRServletURL, java.lang.String userName, java.lang.String password, java.lang.String proxyUserName, java.lang.String proxyPassword)
          Client constructor for http connections to call services with the given security credentials
 
Method Summary
 JSONResponse callAService(java.lang.String service, java.lang.String operation, java.util.Map<java.lang.String,java.lang.Object> headers, java.lang.Object... parameters)
          Calls the remote the servlet for the given service and the operation.This method generates and uses a UUID as message identifier.
 JSONResponse callAServiceWithMID(java.lang.String id, java.lang.String service, java.lang.String operation, java.util.Map<java.lang.String,java.lang.Object> headers, java.lang.Object... parameters)
          Calls the remote the servlet for the given service and the operation.
 void setCredentials(java.lang.String userName, java.lang.String password)
          Sets user name & password for the server authentication
 void setProxyCredentials(java.lang.String userName, java.lang.String password)
          Sets username & password for the proxy authentication
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JSONRRClient

public JSONRRClient(java.lang.String jsonRRServletURL)
             throws java.net.MalformedURLException
Client constructor for http connections to call service anonymously

Parameters:
jsonRRServletURL - JSON Request Response Servlet Url
Throws:
java.net.MalformedURLException

JSONRRClient

public JSONRRClient(java.lang.String jsonRRServletURL,
                    java.lang.String userName,
                    java.lang.String password)
             throws java.net.MalformedURLException
Client constructor for http connections to call services with the given security credentials

Parameters:
jsonRRServletURL - JSON Request Response Servlet Url
userName - username for the authentication
password - password credential for the authentication
Throws:
java.net.MalformedURLException

JSONRRClient

public JSONRRClient(java.lang.String jsonRRServletURL,
                    java.lang.String userName,
                    java.lang.String password,
                    java.lang.String proxyUserName,
                    java.lang.String proxyPassword)
             throws java.net.MalformedURLException
Client constructor for http connections to call services with the given security credentials

Parameters:
jsonRRServletURL - JSON Request Response Servlet Url
userName - username for the authentication
password - password credential for the authentication
proxyUserName - proxy server username
proxyPassword - proxy server password credential for the authentications
Throws:
java.net.MalformedURLException
Method Detail

setCredentials

public void setCredentials(java.lang.String userName,
                           java.lang.String password)
Sets user name & password for the server authentication

Parameters:
userName -
password -

setProxyCredentials

public void setProxyCredentials(java.lang.String userName,
                                java.lang.String password)
Sets username & password for the proxy authentication

Parameters:
userName -
password -

callAService

public JSONResponse callAService(java.lang.String service,
                                 java.lang.String operation,
                                 java.util.Map<java.lang.String,java.lang.Object> headers,
                                 java.lang.Object... parameters)
                          throws java.io.IOException,
                                 JSONException,
                                 TransformationException,
                                 TransformationNotSupportedException
Calls the remote the servlet for the given service and the operation.This method generates and uses a UUID as message identifier.

Parameters:
service - service name
operation - operation name
headers - Header part of the message as given string,object map
parameters - operation parameters, message payload
Returns:
the result will be wrapped in the JSONResponse as error or response
Throws:
java.io.IOException - throws when an exception happens when posting request to the given url
JSONException - throws if an exception happens when preparing request
TransformationException - throws if an exception happens during JSON-Java transformations or vice versa
TransformationNotSupportedException

callAServiceWithMID

public JSONResponse callAServiceWithMID(java.lang.String id,
                                        java.lang.String service,
                                        java.lang.String operation,
                                        java.util.Map<java.lang.String,java.lang.Object> headers,
                                        java.lang.Object... parameters)
                                 throws java.io.IOException,
                                        JSONException,
                                        TransformationException,
                                        TransformationNotSupportedException
Calls the remote the servlet for the given service and the operation.

Parameters:
service - service name
operation - operation name
headers - Header part of the message as given string,object map
parameters - operation parameters, message payload
Returns:
the result will be wrapped in the JSONResponse as error or response
Throws:
java.io.IOException - throws when an exception happens when posting request to the given url
JSONException - throws if an exception happens when preparing request
TransformationException - throws if an exception happens during JSON-Java transformations or vice versa
TransformationNotSupportedException