Click here to Skip to main content
15,895,779 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, I am New in this web service, I created web service using java and use JsonObject(Gson).My web service run successfully.But when I paste my URL into browser it shows me fixed pattern i.e list of method, result part and input format . Actually it directly not showing my result.So where is my mistake? whether I considering wrong URL? I can not find it. I did following code for that and this is final URL which i got in web service client test.

http://localhost:8080/WebClient/sampleConnectionserverProxy/TestClient.jsp
Java
package web; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.Statement; import com.google.gson.JsonArray; import com.google.gson.JsonObject; //import com.google.gson.JsonElement; public class Connectionserver { public String get() { JsonObject result = new JsonObject(); JsonArray jsonArray = new JsonArray(); String s= null; try { Class.forName("com.mysql.jdbc.Driver"); Connection conn = DriverManager.getConnection( "jdbc:mysql://localhost/web", "root", "mysql"); Statement stmt = conn.createStatement(); String sql = "select * from service"; ResultSet rs = stmt.executeQuery(sql); System.out.println("sucessful"); ResultSetMetaData rsmd = rs.getMetaData() ; while (rs.next()) { JsonObject obj = new JsonObject(); for( int i = 1 ; i <= rsmd.getColumnCount() ; i ++ ) { obj.addProperty(rsmd.getColumnName(i), rs.getObject(rsmd.getColumnName(i)).toString()); } jsonArray.add(obj); } result.add("result", jsonArray); System.out.println(result); s=result.toString(); System.out.println(s); } catch (Throwable t) { result.addProperty("error", t.getLocalizedMessage()); t.printStackTrace(System.err); }
return s; }
}
Posted
Updated 24-Nov-14 1:05am
v3
Comments
Sinisa Hajnal 20-Nov-14 2:27am    
If you're seeing the list of methods with their signatures your service works as expected.

Web service is not a web page to be accessed through the browser. You can test it by calling the methods from your application and checking the results, not by copying its URL into the browser.
Member 11239451 20-Nov-14 2:41am    
Thank you so much sir. I will try it in this way.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900