servicestack

User authentication when consuming a REST webservice with ServiceStack

南笙酒味 提交于 2019-12-09 04:22:59
问题 The ServiceStack docs are full of examples on how to use server side implementation of authentication of a user. But how does one set the user credentials on the client side? I use ServiceStack to consume a JSON REST service like this: var restClient = new JsonServiceClient (baseUri); var response = restClient.Get<MyResponse> ("/some/service"); How can I add any form of authentication to the request? The webservice I want to consume uses OAuth 1.0 , but I am interested in adding custom

deserialize json into list of anonymous type

柔情痞子 提交于 2019-12-08 20:13:42
问题 I have a json as below : "[{"a":"b","c":"d"},{"a":"e","c":"f"},{"a":"g","c":"h"}]" now I want to deserilize this into a list of objects of anonymous type "foo" var foo=new { a=string.empty , c=string.empty }; the code is : ServiceStackJsonSerializer Jserializer = new ServiceStackJsonSerializer(); dynamic foos = Jserializer.Deserialize<List<foo.GetType()>>(jsonString); but not working . update : replacing ServiceStack with JavascriptSerializer and passing dictionary[] solved the problem

ntext in ServiceStack.OrmLite

强颜欢笑 提交于 2019-12-08 19:21:10
问题 how can i have nText datatype in ServiceStack.OrmLite Code first ? public class Email { [AutoIncrement] public long ID { get; set; } public DateTime Date { get; set; } public string From { get; set; } public string Subject { get; set; } nText => public string Body { get; set; } } if i use string datatype , ormlite generate nVarchar(8000) in database i need more than 8000 character for data 回答1: You need to convert your Body type to byte[] from string for ServiceStack.OrmLite to use the

Service Stack/MVC: “AppHostBase.Instance has already been set” error - but can't understand why/how to prevent

六月ゝ 毕业季﹏ 提交于 2019-12-08 16:09:28
问题 I'm trying to implement ServiceStack into my MVC3 project, and am following the tutorial at: http://www.servicestack.net/ServiceStack.Hello/ My Global.asax.cs now looks like: public class MvcApplication : System.Web.HttpApplication { public class Hello { public string Name { get; set; } } public class HelloResponse { public string Result { get; set; } } public class HelloService : IService<Hello> { public object Execute(Hello request) { return new HelloResponse { Result = "Hello, " + request

Does ServiceStack.Text offer pretty-printing of JSON?

China☆狼群 提交于 2019-12-08 15:57:40
问题 TL;DR: Is there a built-in way in ServiceStack.Text to produce pretty-printed JSON? I am using ServiceStack.Text for doing JSON serialization. It works really good so far, but the created JSON (using .ToJSON() ) is not formated with whitespaces or newlines (most likely to save space when sending over the network). However, in some circumstances it would be nice to have the JSON formatted for easier human-readability. The .Dump () method does some sort of formatting, however does not produce

How do I get ServiceStack binaries for use with the FOSS exception?

一笑奈何 提交于 2019-12-08 14:16:26
I am trying to build ServiceStack binaries for use with an open source project. First, I tried following the recommendations in this SO answer , by using the DLLs in the lib folder of the ServiceStack repo. However, amongst others, ServiceStack.Logging and some of the OrmLite DLLs are missing there. I then tried building the missing DLLs from the source code, but the OrmLite projects refer to a signed ServiceStack.Interfaces DLL in the lib folder, while for instance ServiceStack.Logging.NLog has a project reference to the ServiceStack.Interfaces project, which then results in an unsigned

How to Nak a ServiceStack RabbitMQ message within the RegisterHandler, Part 2

心已入冬 提交于 2019-12-08 11:33:43
问题 As a follow up to my original question, when throwing exceptions from my web service, they are converted by ServiceStack into more HTTP friendly response codes, which is problematic for the interested party, a windows service (MQ Logic Server) which only receives a 500 internal server error. Is there a way to persist the OutBoundAgentNotFoundException in the inner exception property so that I can inspect it elsewhere and action off of it? Web service endpoint: //This is a callback that the

Simultaneous login on different machines using oauth provider

让人想犯罪 __ 提交于 2019-12-08 10:38:22
问题 As I asked described here: I am building a service where I have code borrowed from the SocialBootstrapApi. I am specfically using the Linkedin oauth2 provider though. I have no complaints for a single user - the code works nicely, but if the same user logs in simultaneously from two differen machines (using the same linkedin account) the original logins access token is invalidated. While the user stays logged in (because session cookies are already in place) if the user performs an action

How to Nak a ServiceStack RabbitMQ message within the RegisterHandler?

时光怂恿深爱的人放手 提交于 2019-12-08 09:36:41
问题 I'd like to be able to requeue a message from within my Service Endpoint that has been wired up through the RegisterHandler method of RabbitMQ Server. e.g. mqServer.RegisterHandler<OutboundILeadPhone>(m => { var db = container.Resolve<IFrontEndRepository>(); db.SaveMessage(m as Message); return ServiceController.ExecuteMessage(m); }, noOfThreads: 1); or here. public object Post(OutboundILeadPhone request) { throw new OutBoundAgentNotFoundException(); // added after mythz posted his first

How to maintain session information across authentication

给你一囗甜甜゛ 提交于 2019-12-08 09:14:17
问题 I using ServiceStack authentication with a custom session object. I've got everything set up with different authentication providers and everything is working fine. Now a want to store some information in the session before the user is authenticated (Think shopping cart). But we loose that information when the user logs in later. Looking at the code in the documentation this makes sense: Plugins.Add(new AuthFeature(() => new AuthUserSession(), new IAuthProvider[] { new BasicAuthProvider(), /