Hi all, I hope in your help.
I need consume a web service ASP.NET in Android and convert XML output to JSON for correct output in mobile device.
This is my webservice and the error is:
Cannot implicitly convert type 'string' to 'System.Xml.XmlDocument'
Can you help me?
Thanks in advance.
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Services;
using System.Data;
using System.Data.Odbc;
using System.Configuration;
using System.Xml;
using System.Web.Script.Serialization;
using System.Text;
using System.Web.Script.Services;
using Newtonsoft.Json;
[WebService(Namespace = "http://www.XXXXX.com/WebService")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class WebService : System.Web.Services.WebService
{
public XmlDocument GetCustomers()
{
XmlDocument doc =
new XmlDocument();
DataSet YourTableDataSet =
new DataSet("WebService");
using (OdbcConnection conn =
new OdbcConnection(ConfigurationManager.ConnectionStrings["cs"].ConnectionString))
{
OdbcDataAdapter adapter =
new OdbcDataAdapter("SELECT * FROM tbl;", conn);
adapter.Fill(YourTableDataSet, "WebService");
}
doc.LoadXml(YourTableDataSet.GetXml());
return JsonConvert.SerializeXmlNode(doc, Newtonsoft.Json.Formatting.Indented);
}
}