Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9142001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:43:11+00:00 2026-06-17T09:43:11+00:00

I would really like to utilize servicestack for a service I need to write

  • 0

I would really like to utilize servicestack for a service I need to write but I’m hitting a mental block wrapping my mind around how it works, and more precisely how I can make it work for my intents and purposes. I don’t have a strong asp background, mainly backend, so maybe that’s why the mental block.

I have a legacy platform to which I connect via native c++ api. I have warped the native api in cli as a .net class library, this would be my equivalent of the Todo repo being injected in the samples.

The data moving back and forth is exposed in the class lib as value structs. For example account would be defined like this:

struct Account{
  int id;
  string name;
  string password;
  ...
}

Order would be something like this:

struct Order{
  int orderId;
  int account;
  string comment;
  ...
}

The lib exposes a lot of functionality and operations for all sorts of different objects defined similarly to the above. What i’m trying to understand is this:

1) How do I register the api with the container? More precisely, I don’t understand how the Register method knows what type its supposed to get. In the todo sample everything is defined in the same assembly so its hard to see how the backend gets injected.

2) Is there a way to manage the lifecylce of the back end in the framework. Can I make it a singleton across all connections.

3) Do I have to wrap my structs in classes that map fields to a request. Not quiet clear on how the request objects are defined, it seems that the content of the request should be fields that would translate to urls of fieldname/type for operations. If there is a way to not have to wrap, how do I then limit which fields to expose in the api and which not to.

4)Do I absolutely have to create a service per data type, so in the structures above would I have to implement one service for Orders and one for Accounts of is there a way to combine them into one. I love that ss can be converted to talk over mq’s, would making a combined service make it difficult to operate over mq’s in the future, what are the cons to this approach.

5) Lastly, I would like to expose operations in the api that, afaik would violate the rest contract. Something like: archive accounts older then…. This would be an operation that returns success/fail status no update/delete ect. Essentially, drive some functionality via an http request. Is this possible in ss, if so, does using it in this way have any debilitating consequences to the framework’s operation…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:43:11+00:00Added an answer on June 17, 2026 at 9:43 am

    1) To register your API you will want to use the built in IoC with Funq.

    container.Register(c => new LegacyApiService())
           .ReusedWithin(ReuseScope.Container); 
    

    Funq is able to automatically wire these Services in your API Services. Take a look at https://github.com/ServiceStack/ServiceStack/wiki/The-IoC-container.

    You can also resolve anywhere container is available using the TryResolve method.

    2) You can controls the Object lifetime with Funq by specifing ReuseScopes when you register them. You will want to look at

    ReuseScope.Container: Singleton scope 
    // a instance is used per application lifetime
    

    3) You are going to need to create plan old classes (DTOs) for your structs. This is necessary for ServiceStack. All your DTOs public properties will get serialized. You can also optionally use DataMemberAttribute and the IgnoreDataMemberAttribute to control what public properties get serialized.

    4) You will need to have a sservice per request DTO. However, you can keep this code at a minimun and call a centralized business layer. This is necessary since each route + verb needs to have a distinct operation, hence the one service class per DTO.

    5) You can easily define more routes and there is nothing that forces you to adhere to REST rules, you are free to implement the HTTP verbs as you see fit. You can easily create specialized routes on GETs that perform an action such as archiving. There are no debilitating consequences here, just perhaps confusion to your API consumers. Just be sure everyone is clear how the API works with documentation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this isn't a programming question but I would really like the users
I would really like to use SpringSource dm Server, but our customer requires us
I would really like to make maven write the target folder to a different
I would really like to use Korma for my project, but every time I
I would really like some advice here, to give some background info I am
I would really like to do something like this: Callable<MyObject> myCallable = .... Future<MyObject>
I would really like to know how web sites decide what ad to show
I would really like to add an image into the Sandcastle generated help file
I would really like your help in knowing the procedure to delete a .3gp
I'm learning iOS development and would really like to look at an example application

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.