未找到端点元素

Endpointelement not found

我从来没有使用过 SOAP,所以也许很明显我遗漏了一些东西,但是当我使用这个 wsdl 作为连接服务时,有人能告诉我 app.config 中必须有什么 visual studio 与此 wsdl。

目前在 app.config 这是我的数据 :

<configuration>
<startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="academieAPISoap">
                <security mode="Transport" />
            </binding>
            <binding name="academieAPISoap1" />
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="https://tryout.academieportal.nl/api2.0/academieAPI_2.0.php"
            binding="netHttpsBinding" bindingConfiguration="academieAPISoap"
            contract="AcAPI.academieAPISoap" name="academieAPISoap"/>
    </client>
</system.serviceModel>

wsdl url: http://tryout.academieportal.nl/api2.0/academieAPI_2.0.php?wsdl 。 连接的服务以名称 AcAPI 保存。

我遇到的错误:

Unhandled Exception: System.InvalidOperationException: Could not find default endpoint element that references contract 'AcAPI.academieAPISoap' 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.

at System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint, String configurationName) at System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName, Configuration configuration) at System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName) at System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, EndpointAddress address) at System.ServiceModel.ChannelFactory1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress) at System.ServiceModel.ConfigurationEndpointTrait1.CreateSimplexFactory() at System.ServiceModel.ConfigurationEndpointTrait1.CreateChannelFactory() at System.ServiceModel.ClientBase1.CreateChannelFactoryRef(EndpointTrait1 endpointTrait) at System.ServiceModel.ClientBase1.InitializeChannelFactoryRef() at System.ServiceModel.ClientBase`1..ctor() at AcademieApiCall.SoapApiClient..ctor(String user, String pass) in C:\Users\Gebruiker\source\repos\AcademieApiCall\AcademieApiCall\SoapApiClient.cs:line 16 at AcademieApiCall.DataHandler..ctor() in C:\Users\Gebruiker\source\repos\AcademieApiCall\AcademieApiCall\dataHandler.cs:line 22 at AcademieApiCall.Program.ExecuteCsv(String path) in C:\Users\Gebruiker\source\repos\AcademieApiCall\AcademieApiCall\Program.cs:line 33 at AcademieApiCall.Program.Main(String[] args) in C:\Users\Gebruiker\source\repos\AcademieApiCall\AcademieApiCall\Program.cs:line 26

更新: 如果我将引用添加为 Web 引用,那么我会得到其他类型的对象和函数。有人可以解释一下它是如何工作的吗?

App.config 必须存在于发布或调试文件夹中。