我已经在VS2008/中添加了web服务的代理。NET 3.5解决方案。在构造客户端。net时会抛出以下错误:

在ServiceModel客户端配置部分中找不到引用合约“IMySOAPWebService”的默认端点元素。这可能是因为没有为您的应用程序找到配置文件,或者因为在客户端元素中没有找到与此契约匹配的端点元素。

搜索此错误告诉我在契约中使用完整的名称空间。这是我的app.config完整的命名空间:

<client>
  <endpoint address="http://192.168.100.87:7001/soap/IMySOAPWebService"
            binding="basicHttpBinding" bindingConfiguration="IMySOAPWebServicebinding"
            contract="Fusion.DataExchange.Workflows.IMySOAPWebService" name="IMySOAPWebServicePort" />
</client>

我正在运行XP本地(我提到这是因为一些谷歌点击提到win2k3) 将app.config复制到app.exe。配置,所以这也不是问题。

有线索吗?


当前回答

如果你使用WPF应用程序使用PRISM框架,那么配置应该存在于你的启动项目中(即在你的bootstrapper驻留的项目中)。

其他回答

There seem to be several ways to create/fix this issue. For me, the CRM product I am using was written in native code and is able to call my .NET dll, but I run into the configuration information needing to be at/above the main application. For me, the CRM application isn't .NET, so I ended up having to put it in my machine.config file (not where I want it). In addition, since my company uses Websense I had a hard time even adding the Service Reference due to a 407 Proxy Authentication Required issue, that to required a modification to the machine.cong.

代理解决方案:

为了让WCF服务引用工作,我必须从我的DLL的app.config复制信息到主应用程序配置(但对我来说是machine.config)。我还必须将端点信息复制到同一个文件中。一旦我这么做了,它就开始为我工作了。

在我的例子中,我指的是一个图书馆项目的服务,而不是一个创业项目。 一旦我复制<system。serviceModel>节配置主启动项目,问题得到解决。

在任何应用程序的运行阶段,配置将从启动/父项目读取,而不是在单独的子项目中读取自己的配置。

我也有同样的问题。事实证明,对于web REFERENCE,你必须将URL作为构造函数的第一个参数:

new WebService.WebServiceSoapClient("http://myservice.com/moo.aspx");

对于一个新样式的web SERVICE REFERENCE,你必须在配置中提供一个引用端点条目的名称:

new WebService.WebServiceSoapClient("WebServiceEndpoint");

在Web中使用相应的条目。config或App.config:

<client>
      <endpoint address="http://myservice.com/moo.aspx"
        binding="basicHttpBinding" 
        bindingConfiguration="WebService"
        contract="WebService.WebServiceSoap"
        name="WebServiceEndpoint" />
    </client>
  </system.serviceModel>

很难消除“它在旧的程序中工作”的狭隘观点……

好的。我的情况有点不同,但最后我找到了解决办法: 我有一个控制台。exe -> DLL ->调用WS1 -> DLL ->调用WS2

我已经按照建议在Console.EXE.config中配置了WS1和WS2的服务模型。没有解决问题。

但它仍然没有工作,直到我将WS2的WebReference也添加到WS1,而不仅仅是添加到实际创建和调用WS2代理的DLL中。

我得到了同样的错误,我尝试了很多事情,但没有工作,然后我注意到我的“合同”在所有项目中都不一样,我改变了合同,因为在解决方案中所有项目都是一样的,然后它起作用了。 这是项目A

<client>
    <endpoint address="https://xxxxxxxx" binding="basicHttpBinding" bindingConfiguration="basic" contract="ServiceReference.IIntegrationService" name="basic" />
</client>

项目B:

<client>
    <endpoint address="xxxxxxxxxxxxx" binding="basicHttpBinding" bindingConfiguration="basic" contract="ServiceReference1.IIntegrationService" name="basic" />
</client>

最后我将两者都更改为:

<client>
    <endpoint address="https://xxxxxxxxxxx" binding="basicHttpBinding" bindingConfiguration="basic" contract="MyServiceReferrence.IIntegrationService" name="basic" />
</client>