0

In my web application there is a WCF web service. In the following method

public string GetPolicyDetails(GetPolicyDetails_ML ml)
{

    var strFileName = Path.Combine(
        Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
        "log.xml");

    DataTable dt = new DataTable();
    DataSet ds = new DataSet();
    try
    {
        con = new SqlConnection(connectionString);
        con.Open();

        cmd = new SqlCommand("sp_GetPolicyDetails", con) { CommandType = CommandType.StoredProcedure };
        cmd.Parameters.AddWithValue("@policy_id", ml.policyID);
        adp = new SqlDataAdapter(cmd);
        adp.Fill(dt);

        string json = JsonConvert.SerializeObject(dt,Formatting.Indented);
        return json;
    }
    catch (SqlException ex)
    {
        return "fail";
    }
    finally
    {
        con.Close();
        con.Dispose();
    }
}

will return a json string inWCF Test Client. I need to access this method from my tab application. The code i used is

ServiceReference1.Service1Client client = new ServiceReference1.Service1Client();
var  ds = await client.GetPolicyInfoAsync(Convert.ToInt16(txtPolicyNumber.Text));

This will get the response in to the #var ds#. My question is what is the type of this var ds and how to get the Json data out of this variable ds. Thanks in advance.

Sergey Litvinov
  • 7,408
  • 5
  • 46
  • 67
Isanka Lakshan
  • 33
  • 2
  • 10
  • I don't see any `GetPolicyInfoAsync` in the sample provided.As of what provided, the return value of of type `string` and you need to `deserialize` this string to get your `DataTable` back.And what's the purpose of `DataSet ` variable you declared? – Amit Kumar Ghosh Jul 27 '15 at 09:44
  • @AmitKumarGhosh When it is accessed to method in the tab application it gives it as `GetPolicyInfoAsync` .ds was declared to store the return of the method. Datatables are not usable in tab applications I think. Can you suggest me a way get a datatable data through a website and use it in tab application, thank you – Isanka Lakshan Jul 27 '15 at 12:56
  • Did you generated `async` methods in the client? – Amit Kumar Ghosh Jul 27 '15 at 14:07
  • `var ds` will be of whatever type `GetPolicyInfoAsync` returns. – Tim Jul 27 '15 at 17:18

0 Answers0