Thanks very much for the comments so far. Can a ResultSet be serialized though?
Philip -----Original Message----- From: Benjamin Tomasini [mailto:[EMAIL PROTECTED]] Sent: Friday, February 14, 2003 1:44 PM To: [EMAIL PROTECTED] Subject: RE: JDBC-based Web Services (?) I would agree with this. Some ideas, maybe: I would read Microsoft's docs on SQL XML support to understand how they approached it, for some ideas. You probably want to expose things like ResultSets, etc .... Maybe look at other db abstraction projects like Castor, EJB CMP 2.0, and OJB to get some ideas on how to model this. On Fri, 2003-02-14 at 16:40, Michael Yuan wrote: > > If all you want is a data service, you probablly should NOT expose the > connection object itself to the user. Just let the user say what she wants > to query and you can manage the SQL templates/connection pools on the > server side. Plus, I do not see a way to serilaize the "connection" object > in a SOAP message. > > cheers > Michael > ------------------------------------------------------------------------ ---- > Read Michael Yuan's technology articles > http://www.enterprisej2me.com/articles.php > Dr. Dobbs Journal, JavaWorld, IBM developerWorks and more ... > ------------------------------------------------------------------------ ---- > > On Fri, 14 Feb 2003, Philip Li wrote: > > > It's not a real application yet. We are trying to build > > dbms-independent data services. > > > > -----Original Message----- > > From: Benjamin Tomasini [mailto:[EMAIL PROTECTED]] > > Sent: Friday, February 14, 2003 1:27 PM > > To: [EMAIL PROTECTED] > > Subject: Re: JDBC-based Web Services (?) > > > > > > I don't think you want to expose db calls over a web service. That is > > pretty low level. I am curious what application would require such > > features. > > > > On Fri, 2003-02-14 at 16:41, Philip Li wrote: > > > Has anyone implemented a JDBC-based Web Services? I am attempting to > > > implement 3 basic servcies to access a database: > > > > > > 1. openDB()- returns a JDBC Connection object; > > > 2. selectFrom(Connection con, String sql_stmt)- returns the ResultSet > > of > > > a Select statement encoded in sql_stmt; > > > 3. closeDB(Connection con)- close the database connection. > > > > > > I modified the simple client example in Axis User's Guide to access > > the > > > 3 web services above (client code attached below). At this point, > > > openDB returns null. Need some advice or suggestions here. > > > > > > Philip > > > p.s.- client code > > > /********************JDBC Web Services > > > Client****************************/ > > > package com.test; > > > > > > import org.apache.axis.client.Call; > > > import org.apache.axis.client.Service; > > > import org.apache.axis.encoding.XMLType; > > > import org.apache.axis.utils.Options; > > > > > > import javax.xml.rpc.ParameterMode; > > > > > > import java.sql.*; > > > public class jwsChatClient > > > { > > > private String Method; > > > private String ErrMsg; > > > > > > public void jwsChatClient() { > > > Method= "none"; > > > } > > > > > > public Connection jwsOpenDB() { > > > //Web Services endpoint > > > String endpoint = "http://localhost:8000/axis/jspChat.jws"; > > > > > > //method=add or subtract for the calculator services > > > if (! Method.equals("openDB") ) { > > > setErrMsg("Usage: jwsChatClient <openDB()> "); > > > return null; > > > } > > > try { > > > Service service = new Service(); > > > Call call = (Call) service.createCall(); > > > > > > call.setTargetEndpointAddress( new java.net.URL(endpoint) ); > > > call.setOperationName( Method ); > > > > > > call.setReturnClass(Connection.class); > > > > > > Connection conn = (Connection) call.invoke( new Object [] { > > }); > > > setErrMsg("Connected to remote DB via JWS: " + conn); > > > return conn; > > > } > > > catch(Exception E) {setErrMsg("->" + E.toString()); return > > > null;} > > > } > > > > > > public int jwsCloseDB(Connection conn) { > > > //Web Services endpoint > > > String endpoint = "http://localhost:8000/axis/jspChat.jws"; > > > > > > //method=add or subtract for the calculator services > > > if (! Method.equals("closeDB") ) { > > > setErrMsg("Usage: jwsChatClient <closeDB(conn)> "); > > > return -1; > > > } > > > try { > > > Service service = new Service(); > > > Call call = (Call) service.createCall(); > > > > > > call.setTargetEndpointAddress( new java.net.URL(endpoint) ); > > > call.setOperationName( Method ); > > > call.addParameter("op1", XMLType.XSD_ANYTYPE, > > > Connection.class, ParameterMode.IN); > > > > > > call.invoke( new Object [] { conn }); > > > setErrMsg("Connection closed to remote DB via JWS."); > > > return 0; > > > } > > > catch(Exception E) {setErrMsg("->" + E.toString()); return -1;} > > > } > > > > > > public ResultSet jwsSelectFrom(Connection conn, String sqlstr) { > > > > > > //Web Services endpoint > > > String endpoint = "http://localhost:8000/axis/jspChat.jws"; > > > > > > //method=add or subtract for the calculator services > > > if (! Method.equals("selectFrom") ) { > > > setErrMsg("Usage: jwsChatClient <selectFrom(connection, > > > sqlstr> "); > > > return null; > > > } > > > try { > > > Service service = new Service(); > > > Call call = (Call) service.createCall(); > > > > > > call.setTargetEndpointAddress( new java.net.URL(endpoint) ); > > > call.setOperationName( Method ); > > > call.addParameter( "op1", XMLType.XSD_ANYTYPE, > > > Connection.class, ParameterMode.IN ); > > > call.addParameter( "op2", XMLType.XSD_ANYTYPE, String.class, > > > ParameterMode.IN ); > > > call.setReturnClass( ResultSet.class ); > > > > > > ResultSet rs = (ResultSet) call.invoke( new Object [] { conn, > > > sqlstr }); > > > setErrMsg("Got result : " + rs); > > > return rs; > > > } > > > catch(Exception E) {setErrMsg("->" + E.toString()); return > > > null;} > > > } > > > > > > public void setErrMsg(String str1) {ErrMsg = str1;} > > > public String getErrMsg() {return ErrMsg;} > > > > > > public void setMethod(String str1) {Method = str1;} > > > public String getMethod() {return Method;} > > > > > > } > > > > > > >