【发布时间】:2009-07-22 20:08:09
【问题描述】:
我想要一些有关设置 WCF 配置的基本指导。 这是我对 WCF 的第一次认真努力(也是第一篇关于 堆栈溢出)。
我有一个要引用的 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#
【问题讨论】:
-
@marc_s 说 “另一个问题是为什么您只能在智能感知中看到一个端点 - 您是否为两个端点创建了客户端代理?因为它是两个独立的合约,您将需要两个单独的客户端代理。您是如何创建客户端端点的?您也可以发布客户端配置吗?“
标签: c# wcf web-services endpoints