I tried to add a service reference to a WCF service that resides in the same solution from an ASP.NET MVC 4 project but failed. I got a error saying:
I had this error at compile time when trying to return a JObject
as the endpoint result.
I got around it by making the endpoint return object
and having this kind of code:
[WebGet(UriTemplate = "SomeRequest?form_request={form_request}", ResponseFormat = WebMessageFormat.Json)]
public object SomeRequest(string form_request)
{
dynamic result = new JObject();
// some other code
result.status = "success";
return JsonConvert.SerializeObject(result);
}
The jQuery consuming the service via jsonp e.g. $.getJSON('>.svc/SomeRequest', 'form_request=' + webform_as_json, request_callback);
then unpacks the serialized object like so:
function request_callback(response) {
var json = $.parseJSON(response);
if (json.status == 'success') {