Created
September 28, 2011 10:14
-
-
Save mythz/1247567 to your computer and use it in GitHub Desktop.
Hello World ServiceStack ASP.NET Web Service in F#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ Application Inherits="HelloFSharp.Global" %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* Hello World ServiceStack ASP.NET Web Service in F# | |
Instructions: | |
1) download https://github.com/ServiceStack/ServiceStack/downloads | |
2) fsharpc -r:ServiceStack.Common.dll -r:ServiceStack.Interfaces.dll -r:ServiceStack.Text.dll -r:ServiceStack.dll --target:library HelloAsp.fs | |
3) mkdir bin && cp *.dll bin | |
4) echo "<%@ Application Inherits=\"HelloFSharp.Global\" %>" >> Global.asax | |
5) copy Web.config mappings from http://www.servicestack.net/ServiceStack.Hello/ | |
6) xsp4 | |
*) | |
namespace HelloFSharp | |
open System | |
open ServiceStack.ServiceHost | |
open ServiceStack.WebHost.Endpoints | |
type Hello = { mutable Name: string; } | |
type HelloResponse = { mutable Result: string; } | |
type HelloService() = | |
interface IService<Hello> with | |
member this.Execute (req:Hello) = { HelloResponse.Result = "Hello, " + req.Name } :> Object | |
//Define the Web Services AppHost | |
type AppHost = | |
inherit AppHostBase | |
new() = { inherit AppHostBase("Hello F# Services", typeof<HelloService>.Assembly) } | |
override this.Configure container = | |
base.Routes | |
.Add<Hello>("/hello") | |
.Add<Hello>("/hello/{Name}") |> ignore | |
type Global = | |
inherit System.Web.HttpApplication | |
new() = { } | |
member x.Application_Start() = | |
let appHost = new AppHost() | |
appHost.Init() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<configuration> | |
<system.web> | |
<httpHandlers> | |
<add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*"/> | |
</httpHandlers> | |
</system.web> | |
<!-- Required for IIS 7.0 --> | |
<system.webServer> | |
<handlers> | |
<add path="*" name="ServiceStack.Factory" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" /> | |
</handlers> | |
</system.webServer> | |
</configuration> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment