1

Has anyone had success getting servicestack to work with HttpRequestMessage and HttpResponseMessage?

What is the minimum implementation of IHttpRequest and IHttpResponse that servicestack needs in order to properly handle an http request?

nickhar
  • 19,981
  • 12
  • 60
  • 73
Aaron Fischer
  • 20,853
  • 18
  • 75
  • 116

1 Answers1

0

IHttpRequest and IHttpResponse are just normalized lightweight interface wrappers around ASP.NET and HttpListener's server HTTP Request/Response objects. It's purpose is to provide a generic, testable API you can bind against so your services can work in both ASP.NET and HttpListener hosts. They have no connection with HttpRequestMessage / HttpResponseMessage.

Not sure what you're trying to achieve, but you can return a IHttpResult or its de-facto implementation HttpResult to customize the HTTP Headers and body output of your services response.

mythz
  • 141,670
  • 29
  • 246
  • 390
  • I have some code to convert a wcf IncomingWebRequestContext into HttpRequestMessage to allow webapi handle the wcf request. I was looking to do the samething for servicestack. – Aaron Fischer Jul 30 '12 at 05:24
  • You could have a new interface over all of them :) http://xkcd.com/927/ - Seriously tho - I don't think it's a good idea to have a HTTP request flow through 2 different web frameworks - but if you just want to call a ServiceStack service you can just pull it out of the IOC and call it e.g http://stackoverflow.com/a/10572977/85785 otherwise similarly you can call into ServiceStack like the MQ Hosts do https://github.com/ServiceStack/ServiceStack/wiki/Messaging-and-redis – mythz Jul 30 '12 at 05:38
  • I have a different reason. I was building an Alexa skill and using a nuget package that is coupled to `HttpRequestMessage`. I might have to fork the repo and make it support service stack. – gaunacode.com Oct 25 '16 at 17:18