0
我想調用一個WCF服務方法使用POST和發送數據編碼爲json,但不管我不斷收到一個錯誤的請求錯誤。WCF:爲什麼我不斷收到400錯誤的請求錯誤?
這是我的方法簽名:
[WebInvoke(Method = "POST",
RequestFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.WrappedRequest)]
public int Publish(List<MeasurementData> data)
這是我MeasurementData
模型定義:
[DataContract]
public class MeasurementData
{
[DataMember]
public string ReadingDate;
[DataMember]
public int Unit { get; set; }
[DataMember]
public string ParameterAbbreviation { get; set; }
[DataMember]
public decimal Measurement { get; set; }
}
這就是我如何從客戶端調用它:
var data = '[{"Measurement": 12678967.543233, "ParameterAbbreviation": "String content", "ReadingDate": "String content","Unit": 2147483647}]';
$.ajax({
type: "POST",
url: "/SiennaAddMeasurement/Publish",
data: "{ 'data' : '" + data + "' }",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
alert(msg.d);
}
});
有什麼我失蹤?
我遵循該答案的步驟,他們沒有工作。 –