我已经在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。配置,所以这也不是问题。

有线索吗?


当前回答

我遇到过这样的情况,我

WCF服务托管在某处 主要项目 类型为“类库”的消费者项目,该项目具有对WCF服务的服务引用 主项目从使用者项目调用方法

现在Consumer项目已经在<system中设置了所有相关的配置。我的app.config的serviceModel>标签,它仍然抛出与上面相同的错误。

我所做的只是添加了相同的标签<system。serviceModel>到我的主项目的app.config文件,最后我们就可以开始了。

就我的情况而言,真正的问题是读取了错误的配置文件。而不是消费者的app.config,它引用的是主项目的配置。我花了两个小时才弄明白。

其他回答

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

嗨,我也遇到过同样的问题,但是最好的解决方案是让. net来配置你的客户端配置。当我使用http:/namespace/service.svc?查询字符串添加服务引用时,我发现了这一点。wsdl=wsdl0,它不会在客户端创建配置端点。但是当我删除wsdl-wsdl0并且只使用url http:/namespace/service时。Svc,它在客户端配置文件中创建端点配置。简而言之,去掉“?WSDL=WSDL0”。

我也有同样的问题 我正在使用桌面应用程序和全球天气网络服务

我删除了服务引用,并添加了web引用,问题解决了 谢谢

我发现(以及复制到客户端UI的App.config,因为我正在使用一个类库接口),我必须以服务引用的名称为绑定的名称前缀(我的是ServiceReference在下面)。

例如:

<endpoint address="http://localhost:4000/ServiceName" binding="basicHttpBinding"
      bindingConfiguration="BasicHttpBinding_ISchedulerService"
      contract="ServiceReference.ISchedulerService" 
      name="BasicHttpBinding_ISchedulerService" />

而不是默认生成:

<endpoint address="http://localhost:4000/ServiceName" binding="basicHttpBinding"
      bindingConfiguration="BasicHttpBinding_ISchedulerService"
      contract="ISchedulerService" 
      name="BasicHttpBinding_ISchedulerService" />

如果在类库中引用web服务,则必须将app.config复制到windows应用程序或控制台应用程序中

解决方案:将外部项目的配置与类库的wcf配置相同。

为我工作