The current project i am working on is extensively using web services and is made in .net 3.5. Now as we are going for implementation of second phase we are confused if we shoul
With either WCF or ASMX, make sure you are adding your services to your pages by using the asp:ScriptManager tag. It will build JavaScript proxies for you, and the advantage is that you don't have to build any parsing at all, regardless of the underlying protocol. It's very, very nice. This example is ASMX, but it's every bit as clean as using WCF.
Also, you can make ASMX send JSON by adding the ScriptService and ScriptMethod attributes:
_
_
_
_
Public Class HospitalLocationService
Inherits System.Web.Services.WebService
_
_
Public Function GetAll() As List(Of HospitalLocationEntity)
Return (New HospitalLocation()).GetAll().Data
End Function
_
_
Public Function GetByID(ByVal ID As Integer) As HospitalLocationEntity
Return (New HospitalLocation()).GetHospitalLocation(ID).Data
End Function
End Class
Consuming the service, without parsing (this is what the ScriptManager does for you):
function editLocation(id) {
vRIS.HospitalLocationService.GetByID(id, getComplete, getError);
}
function getComplete(results, context, methodName) {
document.all['txtLocation'].value = results.Location;
document.all['txtInterfaceID'].value = results.InterfaceID;
document.all['selActive'].value = results.Active ? "true" : "false";
document.all['hdnLocationID'].value = results.ID.toString();
}
function getError(errorInfo, context, methodName) {
Alert(methodName + " : " + errorInfo);
document.all['txtLocation'].value = "";
document.all['txtInterfaceID'].value = "";
document.all['selActive'].value = "false";
document.all['hdnLocationID'].value = "";
}
Edited to add: With all the above based on ASMX, I'd still go WCF, for versatility and for the ability to define data contracts. Also, investigate WCF RIA Services; they are targeting support for AJAX as well as Silverlight, and it automates much of the configuration of WCF.