我想要一些关于设置我的 WCF 配置的基本指导。这是我对 WCF 的第一次认真努力(也是关于 stackoverflow 的第一篇文章)。
我有一个在我的 Web 项目中引用的 WCF 类库 (APILibrary)。在 wcf 库中,我目前有两个服务 - IAuthService 和 ITradeService。
沿着这些思路,我有三个问题:
1)我的问题(以及这篇文章的最初原因)是当我编译我的应用程序时,我可以在我的网络应用程序中调用 TradeServiceCient 但不能调用 AuthServiceClient。后者不会出现在智能感知中。我有一种感觉,这与它们共享同一个端口(并且只包括一个端点)这一事实有关,但我显然不清楚。
2) 我在开发和测试时尝试同时公开两个服务端点(并且可能更多)。当我转到暂存和托管时,每个端点都有自己的地址。在那之前,我该怎么做(我觉得这与我上面的问题有关)?
3)我注意到在很多帖子中人们都有“客户端”和“服务器”“system.serviceModel”代码的示例。这些独特的文件或标签是否位于我的 WCF 库中的 App.config 文件中?每个人都在做什么?目前,我想我只有服务器端?
这是我目前在我的 App.config 文件中的内容(在我的 WCF 库中):
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<client />
<services>
<service behaviorConfiguration="ApiLibrary.ApiBehavior" name="SpoonSys.Api.Trade.TradeService">
<endpoint address="" binding="wsHttpBinding" contract="SpoonSys.Api.Trade.ITradeService">
<identity>
<dns value="localhost:8731" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8731/Design_Time_Addresses/ApiLibrary/Trade/" />
</baseAddresses>
</host>
</service>
<service behaviorConfiguration="ApiLibrary.ApiBehavior" name="SpoonSys.Api.Authentication.AuthService">
<endpoint address="" binding="wsHttpBinding" contract="SpoonSys.Api.Authentication.IAuthService">
<identity>
<dns value="localhost:8731" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8731/Design_Time_Addresses/ApiLibrary/Authentication/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ApiLibrary.ApiBehavior">
<!-- 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="True" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
我的配置是 ASP.NET / Framework 3.5 / VS 2008 / C#