【发布时间】:2014-02-18 03:26:40
【问题描述】:
我有一个控制台应用程序(即 Project1/Solution1)。我正在从位于单独项目(即 Project1/Soloution2)中的控制台应用程序中调用一个 Web 服务 (.asmx) 通过单个 Web 方法调用两个不同的业务类方法(即 Project2/Soloution2),它们又调用两个不同的外部 wcf 服务。 我正在以编程方式创建端点和绑定元素来调用 wcf 方法。
EndpointAddress ed = new EndpointAddress(rtd.WebServiceUrl);
BasicHttpBinding binding = new BasicHttpBinding("BasicHttpBinding_TestService");
ServiceClient client = new ServiceClient(binding, ed);
string response = client.Getdetails(string input1, string input2)
我收到错误“在配置元素集合中找不到与键 'BasicHttpBinding_TestService' 匹配的元素”虽然我已添加此配置 在我的 app.config 文件中。
我的 app.config 文件中的部分
<binding name="BasicHttpBinding_TestService" closeTimeout="00:00:05"
openTimeout="00:00:05" receiveTimeout="00:00:15" sendTimeout="00:00:05"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2047487456" maxBufferPoolSize="524288" maxReceivedMessageSize="2047487456"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="2047487456"
maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
即使我在我的 web 方法所在的 web.config 文件(即 Project1/Soloution2)和调用控制台应用程序的 app.config 文件中添加了它。
【问题讨论】:
-
与论坛网站不同,我们不使用“谢谢”、“任何帮助表示赞赏”或Stack Overflow 上的签名。请参阅“Should 'Hi', 'thanks,' taglines, and salutations be removed from posts?.
标签: web-services wcf wcf-binding