Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Web Services and the fly likes How to Handel ArrayList and HashMap (java util Pack) in Web Services Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "How to Handel ArrayList and HashMap (java util Pack) in Web Services" Watch "How to Handel ArrayList and HashMap (java util Pack) in Web Services" New topic
Author

How to Handel ArrayList and HashMap (java util Pack) in Web Services

k Jayapradeep
Greenhorn

Joined: Oct 18, 2008
Posts: 6
Hi friends,
I am jayapradeep,

I create java class file which contain method public ArrayList getStockDetail(String cname,String symbol ) ,after that i create WSDL file for that class(Stock).In client side i can not received the return value.so i change the return type as String .
Can you explain for if any alternate for ArrayList, except String return type.

Example code:

public class Stock
{
public ArrayList getStockDetail(String cname,String symbol ) throws Exception
{

ArrayList theResultList = new ArrayList();
Connection aCon = null;
PreparedStatement aPS = null;
ResultSet aRS = null;
StringBuffer stockQuery = new StringBuffer( "" );

stockQuery.append( " SELECT " );
stockQuery.append( " CNAME, " );
stockQuery.append( " CSYSMBOL, " );
stockQuery.append( " MARKETTYPE, " );
stockQuery.append( " CADDRESS, ");
stockQuery.append( " QUOTES_LAST, ");
stockQuery.append( " QUOTES_WH, " );
stockQuery.append( " QUOTES_WL, " );
stockQuery.append( " QUOTES_MC ");
stockQuery.append( " FROM STOCK " );
stockQuery.append( " WHERE CNAME LIKE ? " );
stockQuery.append( " OR CSYSMBOL Like ? " );

System.out.println("---------------------");
System.out.println(stockQuery);
System.out.println("---------------------");

try
{
aCon = ConnectionConf.getConnection();
aPS = aCon.prepareStatement( stockQuery.toString() );


aPS.setString( 1, cname );
aPS.setString( 2, symbol.toUpperCase() );

HashMap htTemp = null;
for( aRS = aPS.executeQuery(); aRS.next(); theResultList.add(htTemp) )
{
htTemp = new HashMap();
htTemp.put( "CNAME" , aRS.getString( "CNAME" ) );
htTemp.put( "CSYSMBOL" , aRS.getString( "CSYSMBOL" ) );
htTemp.put( "MARKETTYPE" , aRS.getString( "MARKETTYPE" ) );
htTemp.put( "CADDRESS" , aRS.getString( "CADDRESS" ) );
htTemp.put( "QUOTES_LAST" , aRS.getString( "QUOTES_LAST" ) );
htTemp.put( "QUOTES_WH" , aRS.getString( "QUOTES_WH" ) );
htTemp.put( "QUOTES_WL" , aRS.getString( "QUOTES_WL" ) );
htTemp.put( "QUOTES_MC" , aRS.getString( "QUOTES_MC" ) );
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
aCon.close();
aRS.close();
}
return theResultList;
}

}
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41170
    
  45
You should use an array instead: http://www.ibm.com/developerworks/xml/library/ws-tip-coding.html

In the future, please UseCodeTags when posting code of any length. It's unnecessarily hard to read as it is, making it more likely that people will skip it altogether.


Ping & DNS - my free Android networking tools app
 
Don't get me started about those stupid light bulbs.
 
subject: How to Handel ArrayList and HashMap (java util Pack) in Web Services
 
Similar Threads
Returning arrayList and Final line value alone getting printed in jsp
Multiple DB access Exception
Velocity question
Confused whether Error is related to TLD
constructor with private access modifier