TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sharad Gupta
97
19.7k
8.6m
Calling Web Service Method in c#
Aug 11 2015 12:56 AM
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.
Reply
Answers (
11
)
how to pass byte[] to web service
USSD webservice - C#