0

My problem is that I want to send post request with serialized object to WCF method Here is my code.

[Serializable]
public class StandardCardModel
{
    public string lang { get; set; }
    public string app_source { get; set; }
    public string card { get; set; }
}

[ServiceContract]
public interface IService1
{
    [OperationContract]
    [WebInvoke(Method = "POST",
        RequestFormat = WebMessageFormat.Json,
        ResponseFormat = WebMessageFormat.Json,
        BodyStyle = WebMessageBodyStyle.Wrapped,
        UriTemplate = "GetLastTransactions")]
    LastTransactionsResult GetLastTransactions(StandardCardModel scm);

Now I want to call 'GetLastTransactions' with param :

{
 "lang": "en",
 "app_source": "TestSource",
 "card": "1111"
}

To be clear, I don't want to send JSON with param name as object. ex :

{"scm":{....}}

I am getting null in scm. Any suggestions? Thanks

Jan Köhler
  • 5,817
  • 5
  • 26
  • 35
  • I found an answer to my question [here][1]. Thanks [1]: http://stackoverflow.com/questions/13915765/how-to-pass-and-consume-a-json-parameter-to-with-restful-wcf-service – Sandro Mchedlishvili Jun 06 '15 at 11:05

1 Answers1

0

remove BodyStyle = WebMessageBodyStyle.Wrapped. With BodyStyle = WebMessageBodyStyle.Wrappedthe request must be wrapped.

Amit Kumar Ghosh
  • 3,618
  • 1
  • 20
  • 24