2012-10-24 55 views
0

我嘗試添加Web服務。找不到引用合同的默認端點元素

這是我的配置文件

<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="Service1Soap" 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:51272/Service1.asmx" binding="basicHttpBinding" 
     bindingConfiguration="Service1Soap" contract="ServiceReference1.Service1Soap" 
     name="Service1Soap" /> 
    </client> 
    </system.serviceModel> 

這是我的控制,我調用Web服務。

ServiceReference1.Service1Soap hs = new ServiceReference1.Service1SoapClient(); 
int aa = hs.getStockQty(66); 

但有錯誤..

enter image description here

我怎樣才能解決呢? 謝謝。

+0

你可以發佈你的服務配置文件嗎? – Tim

回答

1

我認爲端點有多個引用,請您刪除引用,然後再添加一個不同的名稱。

如果不是解決方案很簡單。將類庫的配置文件中的端點定義複製到應用程序的配置文件中。

也檢查這個合同的名稱空間「Service1Soap」

相關問題