I set queryMode to 'local' on the combo box so I'm now only seeing 4 and not six requests in Firebug. I think that WCF REST services must rely in sending redirection headers (as shown via Fiddler in IE, whereas Firefox just shows 401 then 200 and not 307 then 200), which might explain why I'm still seeing 4. First two are to authenticate (I turned off anonymous authentication, though for my own testing locally I could probably dispense with that, since my AppPool identity is running as me anyway, so that I can connect to a SQL Server) and the second two are the redirect and the data.
This change to RESTful services is going to take some getting used to, but I can see the benefits in terms of having a well-structed setup instead of the spaghetti code I might otherwise have been tempted to write.
Incidentally, I kept getting 400 bad request errors trying to PUT a JSON object to my service until I discovered that I had to set the content-type header. Here's the ExtJS in case anybody has the same (nightmarish!) problem and discovers this solution:
PHP Code:
var campus = {"Description":"My Campus","ID":0};
Ext.Ajax.request({
url: 'http://localhost/WcfRestService1/Campus/777',
method: 'PUT',
headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' },
jsonData: campus,
success: function(response){
var text = response.responseText;
alert('Response: ' + text);
},
failure: function(response) {
alert('failure');
}
});
Even though I have defaultOutgoingResponseFormat="Json" against the standardEndPoint in my web.config, I thought I'd also send an Accept header for the fun of it. I don't ever want anybody I work with thinking XML is a good idea :-)