简体   繁体   English

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

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

I have a ASP .NET MVC app that I want to be able to connect to SOAP API. 我有一个希望能够连接到SOAP API的ASP .NET MVC应用程序。

I have created a wrapper project were I have my common methods that are working with the API. 我有一个使用API​​的常用方法,所以创建了一个包装器项目。 I have created this wrapper because the file generated by tool is so huge the project build would take ages. 我之所以创建此包装器,是因为该工具生成的文件是如此之大,以至于项目构建需要很长时间。 From api doc site: 从api doc网站:

The tool then generates a single file named EconomicWebService.cs with the proxy code. 然后,该工具会使用代理代码生成一个名为EconomicWebService.cs的文件。 This file can then be included directly in a project (this can slow down your Visual Studio as it is a rather big file) or built into a dll that can be referenced from your project) 然后,可以将该文件直接包含在项目中(这可能会降低Visual Studio的速度,因为它是一个很大的文件),也可以将其内置到可从项目引用的dll中)

I have referenced this wrapper as dll in my class library (middle layer) that is referenced into my MVC application. 我已经在我的MVC应用程序中引用的类库(中间层)中将此包装程序作为dll引用。

Sadly it is not working, and I am getting this error: 遗憾的是,它无法正常工作,并且出现了以下错误:

Could not find default endpoint element that references contract 'S2s.Economic.WebService.EconomicWebServiceSoap' in the ServiceModel client configuration section. 在ServiceModel客户端配置部分中找不到引用合同'S2s.Economic.WebService.EconomicWebServiceSoap'的默认终结点元素。 This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element. 这可能是因为找不到您的应用程序的配置文件,或者是因为在客户端元素中找不到与该协定匹配的端点元素。

Webconfig Web配置

<system.web>
   .....
</system.web>

<runtime>
...
</runtime>

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
         <binding name="EconomicWebServiceSoap">
             <security mode="Transport" />
         </binding>
         <binding name="EconomicWebServiceSoap1" />
      </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="https://api.e-conomic.com/secure/api1/economicwebservice.asmx"
            binding="basicHttpBinding"  bindingConfiguration="EconomicWebServiceSoap"
            contract="PTS.S2s.Economic.WebService.EconomicWebServiceSoap"
            name="EconomicWebServiceSoap" />
    </client>
</system.serviceModel>
</configuration>

我设法在代码中找到一个具有手动端点设置的工作环境。

 EndpointAddress  endpoint = new EndpointAddress( "https://api.e-conomic.com/secure/api1/economicwebservice.asmx" );

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

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