【问题标题】:call from web service to another wcf service throwing an error从 Web 服务调用另一个 wcf 服务引发错误
【发布时间】: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 文件中添加了它。

【问题讨论】:

标签: web-services wcf wcf-binding


【解决方案1】:

查看来自外部 WCF 服务的 web.config 文件中的绑定。 WCF 应用程序的 Web.config 和客户端应用程序的 app.config 中的绑定必须匹配才能使该绑定配置起作用。

【讨论】:

    猜你喜欢
    • 2019-03-06
    • 2017-04-07
    • 2011-01-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-19
    • 1970-01-01
    相关资源
    最近更新 更多