Skip to Content
0
Former Member
Jul 25, 2008 at 09:22 AM

retrieve data from dict table for creating web service

8 Views

hi all,

i need to create a web service for inserting and retrieveing data from dict table.

i hv a method show() in session bean...

public WrapperClass[] show(String title, String desc, String status){
  try
 {
ArrayList arr = new ArrayList();

InitialContext ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("jdbc/SAP" + (String) System.getProperties().get("SAPSYSTEMNAME")+"DB");
Connection conn = ds.getConnection();

PreparedStatement ps = conn.prepareStatement("INSERT into DEMO_TABLE values(title,desc,status)");
ResultSet res = ps.executeQuery();
ps.close();

Statement stmt = conn.createStatement();
ResultSet result = stmt.executeQuery("select * from DEMO_TABLE");
			
while(result.next())
{
WrapperClass wrap = new WrapperClass();
wrap.setDesc(result.getString("DESCRIPTION"));
wrap.setStatus(result.getString("STATUS"));
wrap.setTitle(result.getString("TITLE"));
				
arr.add(wrap);
}
WrapperClass[] wrapArr = new WrapperClass[arr.size()];
			
for(int i=0;i<=arr.size();i++)
{
WrapperClass wrapObj = (WrapperClass)arr.get(i);
wrapArr<i> = wrapObj;
}
conn.close();
return wrapArr;
			
} catch (Exception e) {
// TODO Auto-generated catch block
e.getMessage();
return null;
		} 
	}

Wrapper class is the getter n setter methods.

the ws that is created has no parameters in the response:

wen i import the ws thru adaptive ws model i get these nodes:

*ArrayOfWrapperClass

*Response_show

*Request_show

*WrapperClass

*show

*ShowResponse

bt ideally it shud create 3 nodes....

can u plz tell me where the prob is...

and hw to rectify it..

Thanks And Regards,

ankita

Edited by: Ankita Padhi on Jul 25, 2008 11:23 AM