gpt4 book ai didi

wcf - 在 ServiceModel 客户端配置部分找不到引用契约(Contract)的默认端点元素

转载 作者:行者123 更新时间:2023-12-04 18:06:51 24 4
gpt4 key购买 nike

我正在尝试开发 WCF 服务并将其托管在 IIS 中。但是,当我尝试使用服务时,出现此错误。

Could not find default endpoint element that references contract 'ServiceReference1.IService1' 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 contract could be found in the client element.

我已经使用 WCF 测试客户端测试了 WCF 服务,并且能够成功调用它。

但是当我消费它时同样不起作用。请帮我解决这个问题。

web.config 我在WCF中使用过:

<!--WCF web config-->
<system.serviceModel>
<services>
<service name="ProductServiceLibrary.RuelaService">
<endpoint address="" binding="wsHttpBinding" contract="RuelaService.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>

<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>

当我使用 WCF 服务时,我使用了这个 app.config:

<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" />
</basicHttpBinding>
</bindings>
<client>
<!--URL where I have hosted my WCF http://localhost:9999/Service1.svc-->
<endpoint name="BasicHttpBinding_IService1"
address="http://localhost:9999/Service1.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1"
contract="ServiceReference1.IService1" />
</client>
</system.serviceModel>


[1]: http://i.stack.imgur.com/djQoN.png

最佳答案

该服务似乎公开了与客户端配置不同的契约(Contract)。

服务:

<endpoint address="" binding="wsHttpBinding" 
contract="RuelaService.IService1">

客户:

 <endpoint name="BasicHttpBinding_IService1" 
address="http://localhost:9999/Service1.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1"
contract="ServiceReference1.IService1" />

所以某处不匹配。

关于wcf - 在 ServiceModel 客户端配置部分找不到引用契约(Contract)的默认端点元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24530448/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com