开发者

The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter

开发者 https://www.devze.com 2023-03-15 04:23 出处:网络
I am creating an array in my jquery code then am calling stringify to make it as json data and then am calling a service that receives an object , but unfortunately I am getting this error , and this

I am creating an array in my jquery code then am calling stringify to make it as json data and then am calling a service that receives an object , but unfortunately I am getting this error , and this error is caused by the fact that my object consists of array properties , I have the same code and it's all working fine when my object is only strings and numbers....this is a part of my object

[Serializable]
[DataContract]
public class ImagesEditInfo
{

    [DataMember(IsRequired=true)]
    public int[] Image开发者_StackOverflow中文版Ids
    {
        get;
        set;
    }

}

can anyone help please?


What does your service look like and could you provide some sample requests?

I approximately use this for service calls

    $.ajax({
        type: 'POST',
        url: serviceURL,
        contentType: 'application/json',
        data: JSON.stringify({ serviceParameterName: javascriptObject }),
        success: successFunction,
        dataType: 'json'
    });

in your case your service method would have to be something like this:

    [OperationContract]
    [WebInvoke(ResponseFormat = WebMessageFormat.Json, UriTemplate = serviceURL, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
    public string methodName(ImagesEditInfo serviceParameterName) { }
0

精彩评论

暂无评论...
验证码 换一张
取 消