problem sending significant whitespace in DataSets across webservice (dotnet 2.0)

Discussion in 'ASP .Net Web Services' started by Stephen Ahn, Jul 9, 2007.

  1. Stephen Ahn

    Stephen Ahn Guest

    Using VS2005, dotnet 2.0.
    Here's some code which reproduces the issue.

    Web Service code :
    ==
    [WebMethod]
    public string SendDataSet(DataSet ds)
    {
    DataRow dr = ds.Tables[0].Rows[0];

    string sCurrent = (string)dr[0, DataRowVersion.Current];
    string sOriginal = (string)dr[0, DataRowVersion.Original];

    return "current : " + GetStringAsHex(sCurrent) + ", original : "
    + GetStringAsHex(sOriginal);

    }

    private static string GetStringAsHex(string str)
    {
    System.Text.StringBuilder sb = new
    System.Text.StringBuilder("0x");
    for (int i = 0; i < str.Length; i++)
    {
    sb.AppendFormat("{0:X2}", (int)str);
    }

    return sb.ToString();
    }
    ==

    Run this code on the client end :
    ==
    private void bDataSetTest_Click(object sender, EventArgs e)
    {
    DataSet ds = new DataSet();
    DataTable dt = ds.Tables.Add("t");
    dt.Columns.Add("Data", typeof(string));

    DataRow dr = dt.NewRow();
    dr["Data"] = "\n";
    dt.Rows.Add(dr);
    dt.AcceptChanges();
    dr["Data"] = "\n";


    HelloWorldWebServiceTestApp.localhost.HelloWorldWebService ws =
    new HelloWorldWebServiceTestApp.localhost.HelloWorldWebService();
    ws.Url = this.tbUrl.Text.Trim();

    string res = ws.SendDataSet(ds);
    MessageBox.Show(res);
    }
    ==

    The messagebox displays : "current : 0x0A, original : 0x".
    I was expecting : "current : 0x0A, original : 0x0A".

    So, there seems to be a problem with the original value of columns which
    only contain whitespace. The web method does not see exactly what the client
    has sent.

    Any ideas ?
    Thanks,
    Stephen
     
    Stephen Ahn, Jul 9, 2007
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Charles A. Lackman
    Replies:
    1
    Views:
    1,525
    smith
    Dec 8, 2004
  2. mep
    Replies:
    3
    Views:
    352
    Jeremy Sanders
    Jan 26, 2005
  3. infidel
    Replies:
    57
    Views:
    1,081
    Stephen Kellett
    Aug 10, 2006
  4. a01lida
    Replies:
    2
    Views:
    755
    a01lida
    Nov 16, 2008
  5. SMH
    Replies:
    0
    Views:
    269
Loading...

Share This Page