Castle Windsor Wcf设施:端点名称问题

时间:2014-01-29 13:48:44

标签: wcf windsor-facilities

我的应用程序正在尝试使用我有WSDL文件的WebService。所以,我使用SvcUtil.exe生成了一个接口。我在课堂上使用它如下:

namespace ApplicationUsage
{
    public class Usage
    {
        private readonly IExportService _exportServiceProxyClient;

        public Usage(IExportToNavisionService _exportServiceProxyClient)
        {
            _exportServiceProxyClient= exportServiceProxyClient;
        }
}

我正在将“IExportService”注入:

Component.For<IExportService >()     .AsWcfClient(DefaultClientModel.On(WcfEndpoint.FromConfiguration("exportServiceProxyClient")));

我的问题是我被迫在app.config中使用端点名称,与要在其中注入实例的类构造函数(“Usage”)中的属性名称(“exportServiceProxyClient”)相同。我不认为这是个好主意。如果我不这样做,我得到一个例外:

**Could not find endpoint element with name 'exportServiceProxyClient' and contract 'IExportService ' in the ServiceModel client configuration section. 
This might be because no configuration file was found for your application, or because no endpoint element matching this name could be found in the client element.**

我不知道如何解决这个问题。为什么Windsor希望端点名称与注入它的类的构造函数中的变量名相同。

有人可以帮忙吗?

0 个答案:

没有答案