There are a couple of Attributes used to make methods accessible from script:
WebMethodAttributeWebMethod applied, not sure if it means it can only be called from within same network, or not at all.
* ScriptMethodAttribute
WebService Methods, unless they are decorated with ScriptMethodAttribute, will require the request to come in as a POST, not a GET.$.ajax uses GET, consider $.post when working with ASP.NETScriptMethod is required.
* AutomaticFormatSelectionEnabled:
In .NET40, enable automaticFormatSelectionEnabled in config using either standardEndpoint or endpoint behaviours. See this page and this msdn page.
WebMethodAttribute:WebMethod applied, not sure if it means it can only be called from within same network, or not at all.
* ScriptMethodAttribute:
WebService Methods, unless they are decorated with ScriptMethodAttribute, will require the request to come in as a POST, not a GET.$.ajax uses GET, consider $.post when working with ASP.NETPersonally, I don't do WebServices. Period. Pre-SOAP protocol that is depracated.. Use WCF and WebAPI, with WebHttpBehavior, etc.
WebGetAttributeWebHttpBehavior.Examples:
[ServiceContract]
public interface ICalculator
{
[OperationContract]
[WebGet(UriTemplate = "Mult?x={x}&y={y}", BodyStyle = WebMessageBodyStyle.Bare)]
long Multiply(long x, long y);
[OperationContract]
[WebGet(UriTemplate = "Div?x={x}&y={y}", RequestFormat = WebMessageFormat.Xml)]
long Divide(long x, long y);
[OperationContract]
[WebGet(ResponseFormat= WebMessageFormat.Json)]
long Mod(long x, long y);
}
WebInvokeSystem.ServiceModel.WebExample:
[ServiceContract]
public interface ICalculator2
{
[OperationContract]
[WebInvoke]
long Add(long x, long y);
[OperationContract]
[WebInvoke(UriTemplate = "Sub?x={x}&y={y}")]
long Subtract(long x, long y);
[OperationContract]
[WebInvoke(UriTemplate = "Mult?x={x}&y={y}", BodyStyle = WebMessageBodyStyle.Bare)]
long Multiply(long x, long y);
[OperationContract]
[WebInvoke(UriTemplate = "Div?x={x}&y={y}", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Xml, ResponseFormat=WebMessageFormat.Xml)]
long Divide(long x, long y);
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "Mod?x={x}&y={y}")]
long Mod(long x, long y);
}