Hello World The Rest Files Redis StackOverflow REST at the Movies Northwind Database Ajax Client Soap 1.2

# Calling web services using Silverlight

For performance reasons, the preferred to call ServiceStack services for Silverlight clients is using standard DataContracts via the XML endpoint at:
~/servicestack/xml/reply/{ServiceName}

As Silverlight is a different target runtime you will not be able to reference the dll's that contain your DTO types directly. Insead you can copy the DataContract's into your Silverlight Project and use them 'as-is', as done in this example.

#### 1. First step is to initialize the ServiceClient

`//Create a XmlServiceClient passing in the baseUrl where your services are hosted. this.ServiceClient = new XmlServiceClient( "http://localhost/ServiceStack.Examples.Host.Web/ServiceStack");`

#### 2. Ater that calling a service becomes as easy as:

`var request = new GetFactorial { ForNumber = 3 }; //Note: As this is a synchronous request it should always be run in a backround thread. this.ServiceClient.Send<GetFactorialResponse>(request, response => Console.WriteLine(response.Dump()));`

#### 3. Try the live examples yourself:

#### 4. View the source code online or Download:

The complete source code for this example is viewable online or available to download as zip package from the link below: