Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
11
Reply
Calling Web Service Method in c#
Sharad Gupta
Aug 11 2015 12:56 AM
852
Reply
Hi
I am calling a web service method void type
[WebMethod(enableSession: true)]
public void BRANCHES(String desc)
{
DataTableToJSON(ds.Tables[0]);
return;
}
public void DataTableToJSON(DataTable table)
{
List<Dictionary<string, object>> list = new List<Dictionary<string, object>>();
foreach (DataRow row in table.Rows)
{
Dictionary<string, object> dict = new Dictionary<string, object>();
foreach (DataColumn col in table.Columns)
{
dict[col.ColumnName] = row[col];
}
list.Add(dict);
}
System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
String abcd = serializer.Serialize(list).Replace("[", "").Replace("]", "");
HttpContext.Current.Response.BinaryWrite(encoding.GetBytes(abcd));
}
but when i calling this we service method in my page it gives a error "Response is not well-formed XML"
how can i solve it .
basically this method firstly serializer
"System.Web.Script.Serialization.JavaScriptSerializer serializer" in format.
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
11
)
Next Recommended Forum
how to pass byte[] to web service
USSD webservice - C#