1

I want to send the list of same-type items via GET to my WCF service. For example :

MySite.com?MyService.svc\MyMethod?Id=1&Id=2&Id=3 .....

And my method

[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Json)]
public void MyMethod( ???????? )
{
 //here i want to get the list of all the id's i've sent
}

Or may be there is another way to send such data (i mean, 'an array' of Id's with random length

UPD : I've tried a List and string [] (anyway, it is the string yeah, but) but Exception says : 'type 'System.String[]' is not convertible by 'QueryStringConverter'.'

V319
  • 150
  • 1
  • 13
  • I've tried a List and string [] (anyway, it is the string yeah, but) but Exception says : 'type 'System.String[]' is not convertible by 'QueryStringConverter'.' – V319 Apr 02 '14 at 14:40

1 Answers1

0

You can try to use params keyword. Something like:

public void MyMethod(params object[] list)
{
    // access by index like list[0] etc.
}

Instead of object type u can use int or string if you need.

You can read more about params at http://msdn.microsoft.com/en-us/library/w5zay9db.aspx .

prvit
  • 956
  • 3
  • 9
  • 22
  • Thanks, but i still have an error like ... has a query variable named 'list' of type 'System.Object[]', but type 'System.Object[]' is not convertible by 'QueryStringConverter'. – V319 Apr 02 '14 at 15:00
  • 1
    @V319 mb this topic will help you http://stackoverflow.com/questions/6445171/passing-an-array-to-wcf-service-via-get – prvit Apr 02 '14 at 15:22