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

S

Stephen Ahn

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,787
Messages
2,569,630
Members
45,334
Latest member
66Zeinab9

Latest Threads

Top