Plugging holes in the universe, what are you doing today? RSS 2.0
 Thursday, February 19, 2009

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&amp; completedSynchronously) +155

Thursday, February 19, 2009 8:44:39 PM UTC  #    -

Now Playing
Top Artists This Week
Fluff

Powered by FeedBurner
Categories
Archive
<February 2009>
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
1234567
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010
Kevin Kenny
Sign In
Statistics
Total Posts: 207
This Year: 3
This Month: 0
This Week: 0
Comments: 140
All Content © 2010, Kevin Kenny
DasBlog theme 'Business' created by Christoph De Baene (delarou)