Skip to content

Commit 6179819

Browse files
committed
Add service clients section
1 parent f0a580d commit 6179819

File tree

1 file changed

+57
-1
lines changed

1 file changed

+57
-1
lines changed

src/ServiceStack.Hello/default.htm

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ <h1 class="title">Creating a Web service from scratch with Service Stack</h1>
188188
from scratch using <a href="http://www.servicestack.net">Service Stack</a> and VS.NET.
189189
</p>
190190

191+
<a name="nuget"></a>
191192
<h2>Installing via NuGet</h2>
192193
<p>
193194
If you have NuGet you can skip steps 1 - 3 below by installing one of the NuGet Host packages below:
@@ -223,6 +224,7 @@ <h3>
223224
Once installed, you can explore ServiceStack features at <a href="#view-webservice">Viewing your Web Service</a>.
224225
</p>
225226

227+
<a name="manual"></a>
226228
<h2>Install Manually - 1. Creating your application</h2>
227229
<p>
228230
Create a new ASP.NET Web Application by going into Visual Studio
@@ -302,6 +304,7 @@ <h4>The location configuration below hosts your webservices at custom path: <b>/
302304
To avoid conflicts with ASP.NET MVC add ignore rule in Global.asax RegisterRoutes method e.g: <b>routes.IgnoreRoute ("servicestack/{*pathInfo}");</b>
303305
</p>
304306

307+
<a name="create"></a>
305308
<h2>3. Creating your first Web Service</h2>
306309

307310
<p>
@@ -435,6 +438,7 @@ <h4>
435438
</div>
436439

437440

441+
<a name="predefinedroutes"></a>
438442
<h2>XML, JSON,
439443
<a href="https://github.com/ServiceStack/ServiceStack/wiki/HTML5ReportFormat">HTML5</a>,
440444
<a href="https://github.com/ServiceStack/ServiceStack.Text/wiki/JSV-Format">JSV</a>,
@@ -621,6 +625,7 @@ <h4>SOAP EXAMPLE</h4>
621625
</p>
622626

623627

628+
<a name="customroutes"></a>
624629
<h2>REST Web Services</h2>
625630
<p>
626631
A new addition to Service Stack is the ability to define your own custom urls letting you
@@ -667,6 +672,57 @@ <h4><b>[RestService("/hello")]</b></h4>
667672
without messy configuration and generated code mandated by other options.
668673
</p>
669674

675+
<a name="calling"></a>
676+
<h2>Calling Web Services from Code</h2>
677+
<p>
678+
Using DTOs to define your web service interface makes it possible to provide strong-typed generic service clients without any code-gen or extra build-steps,
679+
leading to a productive end-to-end type-safe communication gateway from client to server.
680+
</p>
681+
<p>
682+
C#/.NET Clients can call the above Hello Service using any of the
683+
<a href="https://github.com/ServiceStack/ServiceStack/blob/master/src/ServiceStack.Common/ServiceClient.Web/">JSON, JSV, XML or SOAP Service Clients</a>
684+
with the code below:
685+
</p>
686+
687+
<code class="csharp">var response = client.Send&lt;HelloResponse&gt;(new Hello { Name = "World!" });
688+
Console.WriteLine(response.Result); // => Hello, World
689+
</code>
690+
<h4>Async Example</h4>
691+
<code class="csharp">client.SendAsync&lt;HelloResponse&gt;(new Hello { Name = "World!" },
692+
r => Console.WriteLine(r.Result), (r, ex) => { throw ex; });
693+
</code>
694+
695+
<p>
696+
The Service Clients use the automatic <a href="#predefinedroutes">Pre-Defined Routes above</a>.
697+
</p>
698+
<p>
699+
In addition, the Service Clients also provide HTTP Verbs (Get, Post &amp; PostFile, Put, Delete) letting you call custom user-defined routes REST-fully e.g:
700+
</p>
701+
702+
<code class="csharp">var response = client.Get&lt;HelloResponse&gt;("/hello/World!");
703+
Console.WriteLine(response.Result); // => Hello, World
704+
</code>
705+
<h4>Async Example</h4>
706+
<code class="csharp">client.GetAsync&lt;HelloResponse&gt;("/hello/World!",
707+
r => Console.WriteLine(r.Result), (r, ex) => { throw ex; });
708+
</code>
709+
710+
<h3>MonoTouch</h3>
711+
<p>
712+
Due to iOS's <a href="http://docs.xamarin.com/ios/about/limitations">No-JIT restrictions</a>, MonoTouch apps will need to use these
713+
<a href="https://github.com/ServiceStack/ServiceStack/tree/master/release/latest/MonoTouch">custom builds of ServiceStack's Serializers and Service Clients</a>.
714+
</p>
715+
716+
<h3>JavaScript</h3>
717+
<p>
718+
As ServiceStack returns 'clean responses' (i.e. your Serialized DTOs as-is), it can easily be called with other existing Http or Ajax clients, e.g. using jQuery:
719+
</p>
720+
<code class="csharp">$.getJSON('servicestack/hello/World!', function(r){
721+
alert(r.Result);
722+
});
723+
</code>
724+
<button onclick="$.getJSON('servicestack/hello/World!', function(r){ alert(r.Result); });">Try It</button>
725+
670726
<h1>Download the code</h1>
671727
<p>
672728
Hopefully this tutorial shows just how easy it is to get started and quickly build
@@ -684,7 +740,7 @@ <h1>Download the code</h1>
684740
<a id="mono" href="http://www.mono-project.com"><img src="img/Mono-powered-big.png" alt="powered by mono" /></a>
685741
</p>
686742

687-
743+
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
688744
<script type="text/javascript">
689745
var _gaq = _gaq || [];
690746
_gaq.push(['_setAccount', 'UA-7722718-7']);

0 commit comments

Comments
 (0)