This is a migrated thread and some comments may be shown as answers.

Remote Connection to Asp.Net WebService

3 Answers 212 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 17 Apr 2012, 01:16 PM
I have downloaded the kendo-exampled-asp-net and have the grid-wcf-crud sample working perfectly. However I am trying to move the WebService to be located remotely.

I have confirmed my remote webservice is servicing data as I can populated an asp.net GridView with the service data.

With the kendu datasource all I have done is change the url: from Products.srv/Read to http://localhost:58871/grid-wcf-crud/Products.svc/Read as per the snip it below. However the data is not populated in the grid. When I check with fiddler no calls are being made to the remote service.

read: {

                        url: "http://localhost:58871/grid-wcf-crud/Products.svc/Read", //specify the URL which data should return the records. This is the Read method of the Products.svc service.

                        contentType: "application/json; charset=utf-8", // tells the web service to serialize JSON

                        type: "POST" //use HTTP POST request as the default GET is not allowed for svc

                    },



3 Answers, 1 is accepted

Sort by
0
Shiva
Top achievements
Rank 1
answered on 19 Apr 2012, 09:43 AM
Even I'm facing exactly this issue. No calls are being visible in fiddler.

This is what I'm doing:

var dataSource = new kendo.data.DataSource({
            transport: {
                read: {
                    // the remote service url
                    url: "http://localhost/WebServices/MyWebService.asmx/GetBBGToADVTransactionsData", // GetBBGToADVTransactionsData is our web method
 
                    contentType: "application/json; charset=utf-8",
 
                    type: "POST",
 
                    // JSONP is required for cross-domain AJAX
                    dataType: "json",
 
                    // additional parameters sent to the remote service
                    data: {
                        //op: "GetBBGToADVTransactionsData"
                    }
                }
            }
    });

Please help.
0
Mark
Top achievements
Rank 1
answered on 19 Apr 2012, 01:37 PM
I've tried different service types and still can't get it to work and spent hours with different samples and connection settings

The only progress I have made is to set the:
dataType: "jsonp" 

fiddler will then show that a request is being made but it doesn't seem to send to the service:
contentType: "application/json; charset=utf-8"

So I receive the return as an XML from the service, which can't be read.

If anyone can help I'm trying to populate a grid from a remote Asp.Net Web Service, the service can be any asp.net type .svc or .asmx etc I don't mind which.

Ideally I want to store the returned data locally and if the Web Service can't be reached use the local copy until a connection to the service is established where the local copy is updated and the grid is refreshed.



0
Mark
Top achievements
Rank 1
answered on 19 Apr 2012, 04:35 PM
I have resolved this issue. And must say I am disappointed as it is a fundamental issue that no-one from Telerik has responded in 2 days, preventing a lot of time waisted by myself and other developers.

The upshot is that browsers are limited to same-domain policies. It is a limitation of jquery/ AJAX not the Kendo UI itself . Thats why in all the examples that work the calls are from the local application or local files. Shive you will see from your sample source above where you have put 'dataType: "json"' it does actually state 'JSONP is required for cross-domain AJAX'

Therefore the solution is to have your service support jsonp. However I have noticed that Safari and Chrome do make AJAX xml and json calls as long as it is not localhost but a full domain name!?!
Tags
Data Source
Asked by
Mark
Top achievements
Rank 1
Answers by
Shiva
Top achievements
Rank 1
Mark
Top achievements
Rank 1
Share this question
or