简体   繁体   English

找不到引用合同的默认端点元素

[英]Could not find default endpoint element that references contract

I'm try to add web services. 我正在尝试添加Web服务。

This is my config file 这是我的配置文件

 <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>

This is my controller where I call the web services. 这是我称为Web服务的控制器。

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

But there is error.. 但是有错误..

在此处输入图片说明

How can I solve it?? 我该如何解决? Thanks. 谢谢。

I think the endpoint has more than one references , could you please delete the reference and add it again with a different name. 我认为端点具有多个引用,请您删除引用并以其他名称再次添加。

if not the solution is simple. 如果不是,解决方案很简单。 Copy the endpoint definitions from the config file ) of the class library to the config file of the application. 将端点定义从类库的config文件复制到应用程序的配置文件。

also check the namespace of this contract "Service1Soap" 还检查此合同“ Service1Soap”的名称空间

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM