Re: Get all data from WebService in Magic XPA 3.2c


Andreas Sedlmeier
 

Hi Neil,

I created you a Magic XPA 3.3 sample, which is available (complete project + export file) here: https://github.com/asedl/XpaDemo/tree/master/Components/Samples/WsDemo . I have only Magic Xpa Single User which is Xpa 3.3. If you cannot import the project in a Xpa application of yours you'll have to downlaod Xpa Single User edition from MSE.

In the sample there's two programs:
GetAuthors which fetches a list of Authors from a .NET webservice method "ListAuthors"
Read_XML_Response which parses the XML response of the ws into a temp. table (sqlite)

For me this works fine, the code of the .NET ws method I paste below.

Good luck and best regards,

Andreas

==

namespace XpaDemoSrv
{
    /// <summary>
    /// Summary description for Books
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class Books : System.Web.Services.WebService
    {
 
        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }
 
        [WebMethod]
        public DataTable ListAuthors() {
 
            // Create a DataTable with a name and add a few records ...
            DataTable dtAuthors = new DataTable(); 
            dtAuthors.Columns.Add("author_id");
            dtAuthors.Columns.Add("author_name");
            dtAuthors.TableName = "dtAuthors";
 
            DataRow newAuthor;
            newAuthor = dtAuthors.NewRow();
            newAuthor["author_id"] = "1";
            newAuthor["author_name"] = "James Joyce";
            dtAuthors.Rows.Add(newAuthor);
            newAuthor = dtAuthors.NewRow();
            newAuthor["author_id"] = "2";
            newAuthor["author_name"] = "Franz Kafka";
            dtAuthors.Rows.Add(newAuthor);
            newAuthor = dtAuthors.NewRow();
            newAuthor["author_id"] = "3";
            newAuthor["author_name"] = "Ernest Hemingway";
            dtAuthors.Rows.Add(newAuthor);
            newAuthor = dtAuthors.NewRow();
            newAuthor["author_id"] = "4";
            newAuthor["author_name"] = "Thomas Mann";
            dtAuthors.Rows.Add(newAuthor);
 
            return dtAuthors;
        }
    }
}

Join main@magicu-l.groups.io to automatically receive all group messages.