I have an MVC application that accepts JSON or XML dpending objects in a request type. This app is based on this article.
To call a method in an MVC application that requires a complex object, I use the following Javascript (JQuery):
function GetUnassignedJob() {
if (isInteger($('#txtDay').val()) && isInteger($('#txtMonth').val()) && isInteger($('#txtYear').val()) && isInteger(intCurrentJobSummaryIndex) && intCurrentJobSummaryIndex > -1) {
$.ajax({
type: 'POST',
contentType: 'application/json; charset=utf-8',
url: 'http://server/api/wip/joboptimise/getlistforids/' + $('#txtYear').val() + '/' + $('#txtMonth').val() + '/' + $('#txtDay').val(),
data: $.toJSON(aJobSummary[intCurrentJobSummaryIndex].JobIds),
dataType: 'json',
cache: false,
beforeSend: function(XMLHttpRequest) { ShowLoading(); },
success: function(data, textStatus) {
try {
ClearUnassignedJobs();
AddUnassignedJobs(data);
}
catch (e) {
alert('GetUnassignedJob():\r\n\r\n' + e.message);
HideLoading();
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
HideLoading();
ShowStatus('unable to retrieve job list');
},
complete: function(XMLHttpRequest, textStatus) {
HideLoading();
}
});
}
else {
ShowStatus('please ensure you have entered numeric values for day, month and year');
}
}
When deployed to a server and accessed from any client on the network, everything works fine. However, when I try to do the same from the server, I get the following error message:
Page: / api / wip / joboptimise / getlistforids / 2010/3/10
Message: the waiting element 'root' from the namespace '' .. Encountered 'None' with the name '', namespace ''.
Source: System.ServiceModel.Web
: System.Object InternalReadObject (System.Runtime.Serialization.XmlReaderDelegator, Boolean)
: System.Runtime.Serialization.Json.DataContractJsonSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName) System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName) System.Runtime.Serialization.Json.DataContractJsonSerializer.ReadObject(XmlDictionaryReader reader) System.Runtime.Serialization.Json.DataContractJsonSerializer.ReadObject( ) at rbm.api.ObjectFilter.ProcessJson(ActionExecutingContext filterContext)
, InputStream HttpContext ! , TcpTrace ( HTTP-), !
,