我的服务将被另一个应用程序在同一个盒子上使用(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