2016-04-03 57 views
0

我有一个ASP .NET MVC应用程序,我希望能够连接到SOAP API。找不到引用合同的默认端点元素

我已经创建了一个包装项目,我有我的API的常用方法。我已经创建了这个包装器,因为工具生成的文件非常大,项目构建需要很长时间。 从API文档网站:

The tool then generates a single file named EconomicWebService.cs with the proxy code. 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)

我已经在我的类库(中间层),其被引用到我的MVC应用程序中引用此包装的DLL。

遗憾的是它不工作,和我收到此错误:

Could not find default endpoint element that references contract 'S2s.Economic.WebService.EconomicWebServiceSoap' in the ServiceModel client configuration section. 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

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

端点必须在“启动项目”的.config,https://msdn.microsoft.com/en-us/library/09138bex(v=vs.90).aspx – Mate

+0

您可以通过“开始的意思项目“? –

+0

是的,我在我的启动项目的webconfig中有它 –

回答

0

我设法找到与代码中手动终点设置一个workarround 。

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