透過 NuGet下載 ServiceStack.Host.AspNet 或 ServiceStack.Host.Mvc
2.開新專案
3.將 Service Stack套用至此專案 //加入參考 ServiceStack.dll
可分:希望有 Web Framework (host from the root path:/)
<location path="servicestack">
<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>
</location>
希望沒有 Web Framework (host web services at :/custompath)<location path="servicestack">
<system.web>
<httpHandlers>
<add path="*"
type="ServiceStack.WebHost.Endpoints.
ServiceStackHttpHandlerFactory, ServiceStack"
verb="*"/>
</httpHandlers>
</system.web>
<!-- Required for IIS 7.0 -->
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add path="*"
name="ServiceStack.Factory"
type="ServiceStack.WebHost.Endpoints.
ServiceStackHttpHandlerFactory, ServiceStack"
verb="*"
preCondition="integratedMode"
resourceType="Unspecified"
allowPathInfo="true" />
</handlers>
</system.webServer>
</location>
4.建立 Web Service
......吧啦吧啦一堆程式碼
5.在 URL中設定用不同的方式(檔案格式)呼叫 Web Service的方法
XML (POX), JSON, JSV, CSV urls:
/servicestack/[xml|json|html|jsv|csv]/[syncreply|asynconeway]/[servicename]
Http post from data:
<form action="servicestack/xml/syncreply/Hello" method="post">
<label>Name:</label>
<input type="text" name="Name" value="World!">
<input type="submit">
</form>
SOAP Web Service urls:
/servicestack/[soap11|soap12]
User defined REST-ful urls:
Accessible via any REST-ful urls defined using the [RestService] Attribute. e.g. in this case:
/servicestack/hello/{Name}
......待續


沒有留言:
張貼留言