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

有线索吗?


当前回答

如果在类库中调用服务,并从另一个项目调用类库,则可能出现此错误。

其他回答

对我来说,解决方案是从客户端web.config中的端点名称属性中删除端点名称 这允许代理使用

ChannelFactory<TService> _channelFactory = new ChannelFactory<TService>("");

锻炼了一整天。 此外,一旦这个修复到位,合同名称是错误的,尽管它在最初的错误出现时是错误的。 再三检查合同名称字符串的人!! 属性:伊恩

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

配置中的名称空间应该反映客户端默认名称空间(如在项目属性中配置的那样)之后的名称空间路径的其余部分。根据你发布的答案,我猜你的客户端被配置为“Fusion.DataExchange”。工作流”名称空间。如果将客户端代码移动到另一个名称空间,则需要更新配置以匹配剩余的名称空间路径。

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)。我还必须将端点信息复制到同一个文件中。一旦我这么做了,它就开始为我工作了。

我也有同样的问题。事实证明,对于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>

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