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>
[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>