0

我的应用程序正在尝试使用我有一个 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 希望端点名称应该与注入它的类的构造函数中的变量名称相同。

有人可以帮忙吗?

4

0 回答 0