[英]Could not find default endpoint element that references contract
我正在嘗試添加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);
但是有錯誤..
我該如何解決? 謝謝。
我認為端點具有多個引用,請您刪除引用並以其他名稱再次添加。
如果不是,解決方案很簡單。 將端點定義從類庫的config文件復制到應用程序的配置文件。
還檢查此合同“ Service1Soap”的名稱空間
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.