我的服務將被另一個應用程序在同一個盒子上使用(Adobe AIR,因爲它發生),我無法運行服務器。我目前正在將WCF服務作爲Windows服務運行,以實現此目的。沒有服務器意味着沒有REST(請糾正我,如果我錯了任何這一點),但我仍然希望我的服務能夠返回JSON。WCF(dotnet 4)是否需要webHttpBinding才能夠輕鬆返回JSON?
我一直在做這方面的研究,並發現很多人在WebHttpBinding中使用REST服務,然後在配置中設置JSON行爲,但出於上述原因,我相信我無法使用REST。
因此,作爲背景,我的問題是:作爲basicHttpBinding或WSHttpBinding(想要避免由於開銷)運行的WCF服務是否可以返回JSON而不必手動滾動它?
如果是這樣,有人會解釋如何解釋嗎?
這裏是我的app.config當前細節服務
<configuration>
<system.serviceModel>
<services>
<service name="WcfProjectLibrary.ProjectService">
<endpoint address="" binding="wsHttpBinding" contract="WcfProjectLibrary.IProjectService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/WcfProjectLibrary/ProjectService/" />
</baseAddresses>
</host>
</service>
</services>
<!--<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>-->
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="True"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
感謝
感謝您的回覆。我的理解是REST端點只能通過Web服務器傳遞,而我的WCF服務是作爲Windows服務運行的。你已經爲我清除了這個,非常感謝你! – sidogg
它在Web服務器上提供了更多功能,因爲某些功能與ASP.NET相關,但核心功能仍可以在任何.NET進程中通過自託管提供。 –
這正是我之後的答案,謝謝! – sidogg