web services - Postgres Java Webservice response issue -
i have webservice use execute postgres queries. problem response anytype{} nothing in it. checked server , seems there no errors in log files.
webservice
@suppresswarnings("unused") public string getinfo() { connection con = null; preparedstatement st = null; resultset rs = null; string url = "jdbc:postgresql://127.0.0.1:5432/uptondb"; string user = "*******"; string password = "******"; string query = ""; string response = ""; int size = 0; initialcontext cxt = null; try { cxt = new initialcontext(); } catch (exception e) { // todo auto-generated catch block e.printstacktrace(); } datasource ds; try { ds = (datasource) cxt.lookup( "java:comp/env/jdbc/postgres" ); } catch (exception e) { // todo auto-generated catch block e.printstacktrace(); } try{ try { class.forname("org.postgres.jdbc.driver"); } catch (classnotfoundexception e) { // todo auto-generated catch block e.printstacktrace(); } con = drivermanager.getconnection(url, user, password); query = "select * \"tblbuildings\""; //query = "select version()"; st = con.preparestatement(query); rs = st.executequery(); while(rs.next()) { response = response + rs.getstring(1); } } catch(sqlexception exc) { logger lgr = logger.getlogger(uppershoreconnection.class.getname()); lgr.log(level.severe, exc.getmessage(), exc); } { try { if (rs != null) { rs.close(); } if (st != null) { st.close(); } if (con != null) { con.close(); } } catch (sqlexception ex) { logger lgr = logger.getlogger(uppershoreconnection.class.getname()); lgr.log(level.warning, ex.getmessage(), ex); } } return response; }
client
public static void main(string[] args) throws exception { final string soap_action = "http://ws.webapp.org/getinfo"; final string method_name = "getinfo"; final string namespace = "http://ws.webapp.org"; final string url = "http://bmoreremembered.com/postgres/services/postdbconnection?wsdl"; /** called when activity first created. */ //string name = "an eastridge garden"; soapobject request = new soapobject(namespace, method_name); //request.addproperty("name", "an eastridge garden"); soapserializationenvelope envelope = new soapserializationenvelope(soapenvelope.ver11); envelope.dotnet = false; envelope.implicittypes = true; envelope.encodingstyle = soapserializationenvelope.xsd; envelope.setoutputsoapobject(request); httptransportse ht = new httptransportse(url); try { ht.setxmlversiontag("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); ht.call(soap_action, envelope); soapobject response = (soapobject) envelope.bodyin; int count = response.getpropertycount(); for(int = 0; < count; i++) { string resultstring= ht.responsedump; system.out.println(resultstring); system.out.println(response.getattribute(i)); } } catch (exception e) { e.printstacktrace(); } }
}
any appreciated. thanks!
Comments
Post a Comment