Ruchit Rami
Ruchit Rami

Reputation: 2282

How to Declare servicestack RestService with list of objects?

I need to pass multiple objects from my application to the rest service that is using servicestack. I need to do something like this

EventLogService : RestServiceBase<List<EventLogData>>

It is not giving any build error. But the name of operation is listed as "List`1" instead of the name given.
I have this line of code to declare AppHost()

public AppHost() : base("Rest WCF", typeof(EventLogService).Assembly) { }

Upvotes: 1

Views: 411

Answers (1)

mythz
mythz

Reputation: 143319

Your AppHost is used to register all your services, not just one of them. ServiceStack will scan through and register all services defined in the Assembly: typeof(EventLogService).Assembly. Likewise the "Rest WCF" name doesn't refer to a single web service, it's refers to all of them and is used on the autogenerated metadata pages.

You should have a Request DTO for each of your services, so if you want to pass in a List<EventLogData> you can do this with:

 public class EventLogs : List<EventLogData> {}

or

 public class EventLogs {
     public List<EventLogData> Items { get; set; }
 }

Upvotes: 1

Related Questions