This project is read-only.

Receiving notifications about the request progress

Handling basic HTTP authentication challenges

Passing additional state information

About one-way service requests

Getting started with TouchStack

Consuming your first Hello World service with TouchStack is as simple as:

1. Creating your contracts

namespace Ro.Norc.ServiceStackClientHello.ServiceModel.Operations
{
	[DataContract(Namespace = "http://schemas.servicestack.net/types")]
	public class Hello
	{
		[DataMember]
		public string Name 
		{
			get;
			set;
		}
	}
	
	[DataContract(Namespace = "http://schemas.servicestack.net/types")]
	public class HelloResponse
	{
		[DataMember]
		public string Result
		{
			get;
			set;
		}
	}
}

2. Create and a new service instance by specifying a service endpoint, an encoder to go with the serialization format of your choice and the proper event handlers to get notified of the operation's success or failure:

private Service<HelloResponse> helloService = null;

/* ... */

helloService = new Service<HelloResponse>("http://www.servicestack.net/ServiceStack.Hello/servicestack");
helloService.Encoder = new ServiceEncoderJson();
helloService.ServiceResult += delegate(object sender, ServiceResultArgs<HelloResponse> args) {
	/* Handle operation success */
};
helloService.ServiceError += delegate(object sender, ServiceErrorArgs args) {
	/* Handle operation failure */
}; 

3. Fire the request

helloService.Send(new Hello() {
	Name = "Touchstack Client"
});

A few notes

As of version 0.3 Beta you are now longer required to specify the full endoint URL (as with the previous version), but only the base URL to which the service client will automatically append the proper parts, in the following order:

  • the part that describes the serialization format (customizable, obtained from the encoder);
  • the part that describes the call type (customizable, obtained from the ServiceCallType instance associated with the service client).

As such, the example shown here will launch its request to

http://www.servicestack.net/ServiceStack.Hello/servicestack/json/syncreply/Hello

However, should you wish to disable this behavior simply set:

helloService.OptAutoAppendEndpointParts = false;

-=-

Last edited Dec 12, 2011 at 10:14 AM by alexandruboia, version 11

Comments

No comments yet.