Link to home
Start Free TrialLog in
Avatar of wildbrookmedia
wildbrookmediaFlag for United States of America

asked on

How can I return xml from a webservice instead of a dataset?

I am trying to load my data that I get from the db as a dataset into xml so i can return it and work with it in Flash.  How can I do this?  (it is a webservice)

[WebMethod(Description = "Return all employees in the database as xml.")]
    public XmlDocument GetAllPeopleRelXML()
    {
        ConnectionStringSettings setting = ConfigurationManager.ConnectionStrings["EmployeeConnectionString"];
        string constring = setting.ConnectionString;

        dsEmployee ds = new dsEmployee();
        SqlConnection conn = new SqlConnection(constring);

        conn.Open();

        dsEmployeeTableAdapters.spSelPersonAllRelTableAdapter personDA = new dsEmployeeTableAdapters.spSelPersonAllRelTableAdapter();

        personDA.Connection = conn;
        personDA.Fill(ds.spSelPersonAllRel);
        XmlDataDocument datadoc = new XmlDataDocument();
        ds.WriteXml(datadoc);

        return datadoc;
    }
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wildbrookmedia

ASKER

Cool, thank you for that.  Do you know if this is slower in working with the data in flash as opposed to returning an array of items or anything?  I haven't found a way to work directly with the dataset so I think converting it to xml like you did above will have to be the way to go...
It depends on what you are trying to serialize and deserialize with SOAP to process the web requests.  It is difficult to say with any certainty without understanding the entire problem space in more detail.

Bob
For now I am just playing with writing webservices in C# and playing with them in flash.  What I am trying to do is write a front end application for a family history web service that I have added a few methods too.

ex here:
http://blogs.msdn.com/coding4fun/archive/2006/10/31/913303.aspx

For the end product I would like to be able to view all family members, update, add, and search for them through the flash interface.
Closed it as you answered my question and I was getting off topic...
thanks again for the quick reply though!
Does your method return a true xml doc or a string that has the format of an xml doc?  I wrote some code in Flash to consume the xml doc but it doesnt seem to recognize it as xml...

Thanks!