I am trying to send an array to a wcf service.
My javascript :
var listoffice = new Array();
var office1 = { officeid : "1", officename : "Bat Cave" };
var office2 = { officeid : "2", officename : "Robin House" };
listoffice[0] = office1;
listoffice[1] = office2;
$.getJSON("ContactService.svc/createnewAwesomeoffice", { listoffice: listoffice }, function (data) {
...
});
Here's the service :
public struct officetoadd
{
public string officeid;
public string officename;
}
[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Json)]
public void createnewAwesomeoffice(List<officetoadd> listoffice)
{
...
}
the problem is the listoffice(in the service) is always null. Am I missing something ?