我已将代理添加到 VS2010/.NET 4solution 的 web 服务。我的机器是windows 7操作系统。构建客户端 .NET 时会引发此错误:
在 ServiceModel 客户端配置部分中找不到名称为“FulfilmentServicesSoap”和合同“FulfimentServiceSoap.FulfilmentServicesSoap”的端点元素。这可能是因为没有为您的应用程序找到配置文件,或者因为在客户端元素中找不到与此名称匹配的端点元素。
我在这里找到了一个关于 SO 的类似问题:
但是,通读此书并尝试一些答案对我没有用。我已经多次编辑了 app.config 文件,包括:
合同="IFulfimentServiceSoap" 名称="FulfilmentServicesSoap" />
和
contract="FulfimentServiceSoap.FulfilmentServicesSoap" name="FulfilmentServicesSoap" />
和
contract="MYFullNamespace.FulfimentServiceSoap.FulfilmentServicesSoap" name="FulfilmentServicesSoap" />
但是,在每种情况下,当我运行我的 Web 服务时,即使我编辑了配置文件,事件查看器也会显示合同“FulfimentServiceSoap.FulfilmentServicesSoap”。我还必须做些什么来获取 app.config 文件中的更改或有任何其他想法吗?
编辑 - 从 app.config 添加绑定信息
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="FulfilmentServicesSoap" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/WLR3.Web.services/FulfilmentServices.asmx"
binding="basicHttpBinding" bindingConfiguration="FulfilmentServicesSoap"
contract="FulfimentServiceSoap.FulfilmentServicesSoap"name="FulfilmentServicesSoap" />
</client>
</system.serviceModel>
编辑 - 创建客户端的代码。
FulfimentServiceSoap.FulfilmentServicesSoap fulfilmentServices = new FulfimentServiceSoap.FulfilmentServicesSoapClient("FulfilmentServicesSoap");