This question is an exact duplicate of:
I am trying to create a webservice which will return more than 1 string. it will return 4 strings. I didt webservices before and I used to return only true or false values. but now I need more data.
here is my webservice.
[WebMethod]
public string get_currency(string date, string cur_code) {
string rtn = "";
try
{
using (SqlConnection conn = new SqlConnection("Data Source=xxx-xxxxx;Initial Catalog=xxx;Persist Security Info=True;User ID=xxx;Password=xxx"))
{
string selectSql = "select date,code,banknote_buying,banknote_selling from Currencies where date = '" + date + "' and code ='" + cur_code + "'";
SqlCommand comm = new SqlCommand(selectSql, conn);
conn.Open();
SqlDataReader dr = comm.ExecuteReader();
if (dr.Read()) {
rtn = dr["date"].ToString() + dr["code"].ToString() + dr["banknote_buying"].ToString() + dr["banknote_selling"].ToString();
}
}
}
catch (Exception ex)
{
return "Fail";
}
return rtn;
}
How can I do return them as a proper SOAP object