• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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;
}

}
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic