hi everybody,
am new to this forum, so thanks for listening.
I work with a web service in Java which don't have attributes. The web service just return the name of the books of a table of my database en SQL by returning an array of strings. Here the code of the web service wich run (by testing it):
public class getLivre {
public String[] consult(){
String tab[] = null;
try {
ArrayList<String> a = new ArrayList<String>();
String str="";
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost/Exercice?user=root&password=oliv45");
String sql = "SELECT Nom FROM TBL_Livre WHERE Quantite >= ?";
PreparedStatement pst = con.prepareStatement(sql);
pst.setInt(1, 1);
ResultSet rst = pst.executeQuery();
while(rst.next())
{
str = rst.getString(1);
a.add(str);
}
int i = 0;
tab = new String[a.size()];
while(i < a.size())
{
tab[i] = a.get(i);i++;
}
con.close();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
return tab;
}
}
}[/COLOR]
In the client, i would like to write the elements of this array with "echo". I've set up the soap client etc and doing print_r i have the result:
object(stdClass)#2 (1) { ["consultReturn"]=> array(6) { [0]=> string(16) "L'ile au trésor" [1]=> string(37) "Harry Potter à l'école des sorciers" [2]=> string(28) "Le club des cinq en vacances" [3]=> string(16) "Les web services" [4]=> string(23) "la convertion amoureuse" [5]=> string(18) "L'écume des jours" } }
Here is my client:
$client = new SoapClient('http://localhost:8080/LocationLivre/services/getLivre?wsdl');
$oReturn = array($client -> __SoapCall('consult', array('string')));
var_dump($oReturn);
Somebody can help me to get the returned array and for exemple doing an echo to write its elements on the HTML page?