エラーが発生します:
例外メッセージは、「受信メッセージに予期しないメッセージ形式 'Raw' があります」です。この操作で想定されるメッセージ形式は、'Xml'、'Json' です。これは、バインディングで WebContentTypeMapper が構成されていないことが原因である可能性があります。詳細については、WebContentTypeMapper のドキュメントを参照してください。詳細については、サーバー ログを参照してください。
私は次のようにWCFサービスへのajax呼び出しを行っています:
function WCFJSON() {
var now = new Date();
var getFromDate = dateToWcf(new Date(now - (60000 * 1440)));
var userid = "1";
m_Type = "POST";
m_Url = "https://dev-04.boldgroup.int/ManitouDashboard/DashboardProxyService.svc/GetStats"
m_Data = "{'fromdate':'" + getFromDate + "'getvaluelist':'[1,2,3]'}";
m_DataType = "json";
m_ProcessData = true;
CallService();
}
function dateToWcf(input) {
var d = new Date(input);
if (isNaN(d)) {
throw new Error("input not date");
}
var date = '\\\/Date(' + d.getTime() + '-0000)\\\/';
return date;
}
function CallService() {
$.ajax({
type: m_Type, //GET or POST or PUT or DELETE verb
url: m_Url, //Location of the service
data: m_Data,
dataType: m_DataType, //Expected data format from server
processdata: m_ProcessData, //True or False
crossdomain: true,
contentType: "application/json",
success: function (msg) { //On Successfull service call
ServiceSucceeded(msg);
},
error: function (jqXHR, textStatus, errorThrown) {
ServiceFailed("jqXHT: " + jqXHR.result + "Text Status: " + textStatus + " Error Thrown: " + errorThrown );
} // When Service call fails
});
}
私のサービス コントラクトは次のように宣言されます。
[ServiceContract]
public interface IDashboardWCFService
{
[OperationContract]
[WebInvoke(UriTemplate = "GetStats", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
Dictionary<int,List<StatValue>> GetStats(DateTime getFromDate, List<int> getValueList);
[OperationContract]
[WebGet(UriTemplate = "GetStatTypes", ResponseFormat = WebMessageFormat.Json)]
List<StatType> GetStatTypes();
}
通話中に何か間違ったことをしていますか?