This is a migrated thread and some comments may be shown as answers.
WCF Not Getting Called at Grid Binding
9 Answers 45 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Craig
Top achievements
Rank 1
Craig asked on 26 Apr 2011, 02:42 PM
I followed the example on the site but for some reason my WCF Service is not getting called when I try to bind.  Here's my latest version of the code, though I've tried many permutations.  Any help would be appreciated.

@(Html.Telerik().Grid<Notes>()
        .Name("NotesGrid")
        .Columns(columns =>
        {
            columns.Bound(o => o.Id).Width(100);
            columns.Bound(o => o.Subject).Width(200);
            columns.Bound(o => o.Date).Format("{0:MM/dd/yyyy}").Width(100);
            columns.Bound(o => o.Person);
        })
                .DataBinding(dataBinding => dataBinding.WebService().Select("net.pipe://localhost:3380/NotesService.svc"))
            .Groupable()
            .Sortable()
            .Pageable()
            .Filterable()
            .Scrollable()

Controller code
public ActionResult Index()
        {
    return View();
        }

WCF Code
[ServiceContract]
    public interface INotesService
{
    [OperationContract]
    GridModel List(GridState state);
}


public GridModel List(GridState state)
{
    Global.Logger.Info("NotesService.Index()");
    IQueryable<Notes> notes = notesRepository.DoQuery();
    return notes.ToGridModel(state);
  
}

9 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 26 Apr 2011, 03:00 PM
Hello Craig, 

The grid supports only HTTP WCF binding because it relies on the XMLHttpRequest object to call the service client-side. You are using different protocol ("net.pipe:") hence the problem. If you must use that protocol you should approach the problem from a different angle:

  1. Configure the grid for ajax binding
  2. In the action method which populates the grid call your WCF service (server side) and return the data.

If you need further assistance you can attach a sample project. We will modify it to demonstrate the described approach.

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Craig
Top achievements
Rank 1
answered on 26 Apr 2011, 04:36 PM
Atanas,

Thanks for the quick response.

I have used the following databinding call as well, with no luck:
.DataBinding(dataBinding => dataBinding.WebService().Select("http://localhost:3380/NotesService.svc"))

The controller method is called, but the web service method is never called.  I have gotten Ajax binding working with the web service but I don't want to lose the built in sorting and filtering functionality which is why I'm trying this approach.

0
Atanas Korchev
Telerik team
answered on 27 Apr 2011, 09:39 AM
Hello Craig,

 This is strange. What happens if you request the same URL in your browser? Is there a chance to send us a sample project? I suspect that either the URL is not accessible at all or the cross domain policy kicks in again and prevents the browser (and the grid) from requesting it via XMLHttpRequest.

Kind regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
lee
Top achievements
Rank 1
answered on 09 Aug 2011, 06:30 PM
I am having the same problem.  Code is same as above.  Problem is that the service is never getting called from the control.
0
Atanas Korchev
Telerik team
answered on 10 Aug 2011, 05:40 AM
Hello Lee, 

I would ask you the same questions:
  1. Is the WCF service in the same domain as the MVC Application?
  2. Have you tried requesting the WCF url in the web browser address bar?
  3. Have you checked what's the server response using a tool such as IE dev toolbar or Firebug?

Providing more info or some sample code would help a lot in troubleshooting.

Regards,
Atanas Korchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

0
lee
Top achievements
Rank 1
answered on 10 Aug 2011, 09:10 PM
1. Yes (Even on the same machine, a testing environment)
2. Yes (I get the .svc page with the wsdl link)
3. Server returns nothing

It doesn't look like the grid ever calls out to the service.  All that we have on the page is an empty grid.  The model works as we have the following on the same page as the grid. 
@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.FirstName)
        </td>


Code looks something like this. 

View code...

@(Html.Telerik().Grid<test2>()      
.Name("Grid")
.Columns(columns =>
{
    columns.Bound(o => o.FirstName);
    columns.Bound(o => o.LastName);
    columns.Bound(o => o.Rating);
    columns.Bound(o => o.BirthDate).Format("{0:MM/dd/yyyy}");
}
)
.DataBinding(dataBinding => dataBinding.WebService().Select("http://localhost:39609/Models/ClientWcf.svc/GetClients"))
)

 

 

Controller code...

public ActionResult Index() 
{
     return View(); 
}

 

 

WCF Code...

 [ServiceContract]
 public interface IService1
  {
     [OperationContract]
     GridModel GetClients(GridState state);
  }

    
   public GridModel GetClients(GridState state)   
    {
        test2DBContext tbl = new test2DBContext();
        IQueryable<test2> clients = from o in tbl.tests2
                                                        select new test2
                                                        {
                                                            FirstName= o.FirstName,
                                                            LastName= o.LastName,
                                                            Rating = o.Rating,
                                                            BirthDate= o.BirthDate
                                                        };

        return clients.ToGridModel(state);
        }
    }

 

0
Atanas Korchev
Telerik team
answered on 11 Aug 2011, 06:46 AM
Hello Lee,

 This is still considered cross domain request and will not work with the grid web service binding:

http://localhost:39609/Models/ClientWcf.svc/GetClients

The web service and your application must live in the same domain (which includes the port as well).

If possible you can try this:
dataBinding.WebService().Select("~/Models/ClientWcf.svc/GetClients"))

If not you can configure the grid for ajax binding and in your action method request the WCF service using server-side code.

Regards,
Atanas Korchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

0
lee
Top achievements
Rank 1
answered on 11 Aug 2011, 03:26 PM
We did try ("~/Models/ClientWcf.svc/GetClients") at first, but still nothing.

0
Atanas Korchev
Telerik team
answered on 11 Aug 2011, 03:48 PM
Hi Lee,

 Then I suggest you try my second suggestion - to request the WCF from the server side.

 The WCF binding from the client-side would work only if your WCF service is not treated as a cross domain request.

Best wishes,
Atanas Korchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Tags
Grid
Asked by
Craig
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Craig
Top achievements
Rank 1
lee
Top achievements
Rank 1
Share this question
or