This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Customer Requirements for Developers and have Marcho Behler on-line!
See this thread for details.
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 Customer Requirements for Developers this week in the Jobs Discussion 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
Rancher

Joined: Mar 22, 2005
Posts: 42956
    
  73
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to Handel ArrayList and HashMap (java util Pack) in Web Services
 
jQuery in Action, 3rd edition