Fiddler to the rescue yet again….
If you’re doing jQuery/AJAX –> web service kinda things like this:
function submitWooshTest() {
var adslOrderID = gQs.get("orderid");
$.ajax({
type: "POST", url: "ScriptServices/WooshTester.asmx/RequestWooshTest",
data: {
adslOrderID: adslOrderID,
faultType: $('#wooshFaultType').val(),
hasWorked: $('#wooshHasWorked').is(':checked'),
disruptive: $('#wooshDisruptive').is(':checked'),
faultDate: $('#wooshFaultDate').val(),
faultTime: $('#wooshFaultHour').val() + ':' + $('#wooshFaultMinute').val()
},
success: function(result) {
$.unblockUI();
$.blockUI({ message: $('#wooshResults') });
showWooshTests();
},
error: function(x, s, e) {
debug(x, s, e);
}
});
}
And the web service end point looks like:
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public int RequestWooshTest(int adslOrderID, string faultType, bool hasWorked, bool disruptive, string faultDate, string faultTime)
{
// etc
}
Don’t forget to configure your web services protocols in your web.config:
<?xml version="1.0"?>
<configuration>
<system.web>
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
</system.web>
</configuration>
Otherwise when accessing your functionality from a browser that isn’t on the localhost you’ll get the following cryptic error message:
System.InvalidOperationException: Request format is unrecognized for URL unexpectedly ending in '/RequestWooshTest.
[InvalidOperationException: Request format is unrecognized for URL unexpectedly ending in '/RequestWooshTest.]
System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response) +405881
System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath) +212
System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated) +47
System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig) +193
System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +93
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155