Getting started with TouchStack

Receiving notifications about the request progress

Handling basic HTTP authentication challenges

Passing additional state information

About one-way service requests

One-way requests allow a fire-and-forget style of calling web services, by not waiting for the entire web-service response. Of course, the web-service you're calling should support this feature (and ServiceStack does), otherwise calling it this way would not make much of a sense. TouchStack also supports this call type and here's how one can use it:

1. When creating your service, specify ServiceResultOneWay as the response type. Actually, setting it to other than that will throw an exception when placing one-way service call types and the reason for this is that for a one-way request there is no particular object contract to use as the response type.

Service<ServiceResultOneWay> service = 
new Service<ServiceResultOneWay>("http://www.servicestack.net/ServiceStack.Hello/servicestack");

2. Set the call type

service.CallType = ServiceCallType.CallOneWay;

3. Optionally, you can bind to the ServiceResult event to inspect the http response status code:

helloService.ServiceResult += delegate(object sender, ServiceResultArgs<ServiceResultOneWay> args) {
	Console.WriteLine(args.Result.ResponseCode)
};

Also, bear in mind that, as stated in the getting started guide, the Service class will automatically append the corresponding endpoint parts to the URL passed in the constructor. As such, assuming that the JSON encoder is used, the request in our example will be sent to

http://www.servicestack.net/ServiceStack.Hello/servicestack/json/asynconeway/YourRequestName

-==-

Last edited Dec 9, 2011 at 4:54 PM by alexandruboia, version 6

Comments

No comments yet.