2014-02-18 103 views
0

我有一個控制檯應用程序(即Project1/Solution1)。我從控制檯應用程序調用一個Web服務(.asmx)在單獨的項目(即Project1/Soloution2) 通過單一網絡方法,可以調用兩種不同的業務類方法(即Project2/Soloution2),後者又調用兩個不同的外部wcf服務。 我以編程方式創建端點和綁定元素來調用wcf方法。從Web服務調用另一個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.config文件中添加了這個在我的Web方法所在(即PROJECT1/Soloution2),並在調用控制檯應用程序的app.config文件。

+0

與論壇網站不同,我們不使用「謝謝」或「任何幫助表示讚賞」,或在[so]上簽名。請參閱「[應該'嗨','謝謝',標語和致敬從帖子中刪除?](http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be -removed - 從 - 個)。 –

回答

0

查看來自外部WCF服務的web.config文件中的綁定。 WCF應用程序的Web.config中的綁定和客戶端應用程序的app.config必須匹配才能使綁定配置生效。

相關問題