I wanted to implement a connection module that creates a web services connection object, and the client code just uses the connection object to establish a connection to the intended web service.
Following code snippet is my intention that client code would use to establish the connection and get the response from the web service...
// 1. WS Driver configurations
String WS_DRIVER_URL = "ws.drivers.webservice1:";
String WS_ENDPOINT = "https://webservice1_endpoint/";
String WS_CONN_URL = WS_DRIVER_URL+WS_ENDPOINT
// 2. Load the required Driver
Class.forName("com.mycomp.wsdrivers.webservice1Driver");
// 3. now get the connection
ws1Connection = DriverManager.getConnection(WS_CONN_URL, WS_CON_CONFIGURATIONS);
// 4. execute (pass the request and get the response)
wsResponse = (webservice1Response) ws1Connection.execute(Request);
YES, with my customized DriverManager/Connection/Driver to connect to web services and not to the Databases. The client needs to connect to multiple web services, and each service will have its custom Driver implementation. However the concept (DB connection) is the same, instead of connecting to DB, I would want to connect to web services.
The purpose which I am trying to get this approach hoping it brings standardized implementation across the client code, and to avoid different implementations for connecting to web services. (even there are cases where various connection implementations for the same web services in the same code base)
Does it make sense, please share your thoughts.
Thank you all for your time.
Aucun commentaire:
Enregistrer un commentaire