We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Sample for Databinding to a webservice

Thread ID:

Created:

Updated:

Platform:

Replies:

114319 Nov 12,2013 11:25 PM Dec 18,2013 05:14 AM ASP.NET MVC (Classic) 6
loading
Tags: Grid
Jeremy Branham
Asked On November 12, 2013 11:25 PM

I think my asmx service is not setup correctly.
I have followed the user guide for binding to a webservice, but I get this error when accessing my webservice method -
Cannot serialize member Syncfusion.Mvc.Grid.GridWebService.Data of type System.Collections.IEnumerable because it is an interface.
 
Here is my Webmethod -

        [WebMethod]
        public virtual GridWebService Index(WebServiceParams webParams)
        {
            IEnumerable<License> licenseList = GetItems().ToList();
            return licenseList.GridWebServiceAction<License>(webParams);
        }

 


Sarath Kumar P [Syncfusion]
Replied On November 20, 2013 08:01 AM

Hi Jeremy,

 

Thanks for using Syncfusion products.

 

We suspect that you have used the code IEnumerable<License> in your cshtml page. Please remove the specified code from your cshtml page to avoid your reported issue.

 

Please refer our online documentation link for further reference.

 

http://help.syncfusion.com/ug/asp.net%20mvc/grid/default.htm#!documents/webservicedatabindin.htm

 

Please let us know if you have need further assistance.

 

Regards,

P.SarathKumar.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


Jeremy Branham
Replied On November 28, 2013 03:23 PM

I am getting this exception when directly accessing the webmethod.
 
I can return a list of objects, but I cannot return a GridWebService object.

Jeremy Branham
Replied On November 28, 2013 05:59 PM

[NotSupportedException: Cannot serialize member Syncfusion.Mvc.Grid.GridWebService.Data of type System.Collections.IEnumerable because it is an interface.]

[InvalidOperationException: Cannot serialize member 'Syncfusion.Mvc.Grid.GridWebService.Data' of type 'System.Collections.IEnumerable', see inner exception for more details.]
   System.Xml.Serialization.StructModel.CheckSupportedMember(TypeDesc typeDesc, MemberInfo member, Type type) +5531266
   System.Xml.Serialization.StructModel.GetPropertyModel(PropertyInfo propertyInfo) +125
   System.Xml.Serialization.StructModel.GetFieldModel(MemberInfo memberInfo) +89
   System.Xml.Serialization.XmlReflectionImporter.InitializeStructMembers(StructMapping mapping, StructModel model, Boolean openModel, String typeName, RecursionLimiter limiter) +247
   System.Xml.Serialization.XmlReflectionImporter.ImportStructLikeMapping(StructModel model, String ns, Boolean openModel, XmlAttributes a, RecursionLimiter limiter) +378
   System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, String ns, ImportContext context, String dataType, XmlAttributes a, Boolean repeats, Boolean openModel, RecursionLimiter limiter) +1734

[InvalidOperationException: There was an error reflecting type 'Syncfusion.Mvc.Grid.GridWebService'.]

Sarath Kumar P [Syncfusion]
Replied On December 4, 2013 05:21 AM

Hi  Jeremy,

 

We regret for the inconvenience caused.

 

We suggest you to refer the below Web service asmx code snippets, cshtml page code snippets for your reference.

 

[Orders.asmx.cs]

 

namespace Syncfusion.Mvc.Grid.Models

{

using System.ComponentModel;

using System.Linq;

using System.Web.Script.Services;

using System.Web.Services;

using MVCSampleBrowser.Models;

using Syncfusion.Mvc.Grid;

using System.Collections;

using System.Xml.Serialization;

using System.Runtime.Serialization;

using System.Collections.Generic;

using System.ServiceModel.Web;

 

[WebService(Namespace = "http://tempuri.org/")]

[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

[ToolboxItem(false)]

[ScriptService]

public class OrdersAsmx : System.Web.Services.WebService

{

[WebMethod]

public GridWebService RenderOrders(WebServiceParams webParams)

{

IEnumerable data = new NorthwindDataContext().OrdersViews.Take(100).ToList();

return data.GridWebServiceAction<OrdersView>(webParams);

}

}

}

 

 

 

[Asmx.cshtml]

 

@(Html.Syncfusion().Grid<OrdersView>("Grid1")

.Caption("Orders")

.WebService(Url.Content("~/Models/Orders.asmx/RenderOrders"))

.Column(column =>

{

column.Add(p => p.OrderID).HeaderText("Order ID").TextAlign(TextAlignment.Right).Width(100);

column.Add(p => p.EmployeeID).HeaderText("Employee ID").TextAlign(TextAlignment.Right).Width(115);

column.Add(p => p.ShipAddress).HeaderText("Ship Address");

column.Add(p => p.ShipCity).HeaderText("Ship City").Width(150);

column.Add(p => p.ShipCountry).HeaderText("Ship Country").Width(170);

})

.EnablePaging().PageSettings(p => p.PageCount(5))

.EnableSorting()

.EnableGrouping().EnableFiltering()

.AutoFormat(Skins.Marble))

 

 

Please let us know if you need further assistance.

 

 

Regards,

P.Sarathkumar.

 

 


Jeremy Branham
Replied On December 14, 2013 01:11 PM

I'm using the most simple test, but I still get the same error.
 
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    [System.Web.Script.Services.ScriptService]
    public class LicenseService : System.Web.Services.WebService
    {
        class test
        {
            public int prop { get; set; }
        }

        [WebMethod]
        public GridWebService Get(WebServiceParams webParams)
        {
            var testList = new List<test>();
            return testList.GridWebServiceAction<test>(webParams);
        }
    }

Rakesh D [Syncfusion]
Replied On December 18, 2013 05:14 AM

Hi Jeremy,

  

We are sorry for inconvenience caused. We are unable to reproduce the issue. We have prepared a simple working sample and the same can be downloaded from the following links.

 

Could you please try the below sample and get back to us whether you are able to reproduce the issue? If not, could you please give more information or by reproducing the issue in the above sample so that we could sort out the issue and provide you with solution. The information provided would be of great help in resolving the issue.

 

Sample :

 

 

Please let us know if you need any further assistance.

 

Regards,

Rakesh D

 



WebServiceDemo_3cab800a.zip

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;