WCF/WF - Calling WCF JSON service with complex type

Asked By Raj Kris on 27-Nov-13 06:53 AM
How do I call this webservice from javascript using JSON?!

Also any help on testing the same directly with the browser will be appreciated.

Snippet
  [OperationContract]
    [WebInvoke(
      Method="GET",
      UriTemplate="SelectionRule/ruleName={ruleName}&lists={lists}",
      RequestFormat=WebMessageFormat.Json,
      ResponseFormat=WebMessageFormat.Json,
      BodyStyle=WebMessageBodyStyle.Wrapped
      )
    ]
    
    [return:MessageParameter(Name="SelectionRule")]
    IList<string> FireSelectionRule(string ruleName, ListEntityParameters[] lists);
Robbe Morris replied to Raj Kris on 27-Nov-13 07:27 AM
JavaScript code:

var record = {}; // create an instance of an object.

   record.FirstName = 'blah';  // type properties exactly as they are in .NET class.
   record.LastName = 'blah';

var list = new Array(); // Use an Array for either .NET arrays or List<T>.
list.push(record);

Call your normal ajax method and pass list as a parameter.