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

Passing parameter to web service

1 Answer 185 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Jonah
Top achievements
Rank 1
Jonah asked on 24 Mar 2013, 01:15 AM
I have a web service that works fine before I pass in any parameter. Once I change the service to take a parameter I return no data. I am fairly new to asmx web services but here is my code for my service as well as the call.

[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 WebService : System.Web.Services.WebService {

    public WebService () {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    List<string> datax = new List<string>();
  [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    [WebMethod]
    public object GetAgent(string agentId)
    {
      
      DataClassesDataContext dc = new DataClassesDataContext();
      var ag = from x in dc.Agents
                select x;
      foreach (var item in ag)
      {
        datax.Add(item.FirstName + " " + item.LastName);
      }
      //JavaScriptSerializer jss = new JavaScriptSerializer();
      //retVal = jss.Serialize(ag);
      return datax;
    }
}


  <script>
    var deviceJDS = new kendo.data.DataSource({
      schema: {
        data: "d"  // ASMX services return JSON in the following format { "d": <result> }. Specify how to get the result.
      },
      transport: {
        read: {
          contentType: "application/json; charset=utf-8",
          type: "POST",
          dataType: "json",
          url: "http://localhost:65205/WebService.asmx/GetAgent",
           data: {agentId: 2}

        }
      }
    });


    $("#listview").kendoMobileListView({
      dataSource: deviceJDS
    });
    var app = new kendo.mobile.Application();
</script>



1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 26 Mar 2013, 10:00 PM
Hello Jonah,

I am afraid that your question is not directly related to the build-in functionality or features that our product offers and as such is out of the scope of the standard support service. Kendo DataSource uses standard jQuery Ajax requests to communicate with the server. If you are able to process parameters send with standard Ajax request, you should not have problems to send same data with the DataSource transport.

Kind regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Data Source
Asked by
Jonah
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or