0

After add an Basic WCF server as Service Reference ,i try to run it and got error :

System.InvalidOperationException: An endpoint configuration section for contract 'AlineTest.ServicesSoap' could not be loaded because more than one endpoint configuration for that contract was found. Please indicate the preferred endpoint configuration section by name. at System.ServiceModel.Description.ConfigLoader.LookupChannel(ContextInformation configurationContext, String configurationName, ContractDescription contract, EndpointAddress address, Boolean wildcard, Boolean useChannelElementKind, ServiceEndpoint& serviceEndpoint) 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 ComboProjectReference.AlineTest.ServicesSoapClient..ctor() in c:\users\nguyen ba nguyen\documents\visual studio 2017\Projects\ComboProjectReference\ComboProjectReference\Connected Services\AlineTest\Reference.cs:line 2898 at ComboProjectReference.Controllers.ValuesController.d__0.MoveNext() in c:\users\nguyen ba nguyen\documents\visual studio 2017\Projects\ComboProjectReference\ComboProjectReference\Controllers\ValuesController.cs:line 28

my code for consuming WCF :

  try
        {
            ServicesSoapClient client = new ServicesSoapClient();
            Task<CustomerAccountInfo[]> GetAccount = client.GetAccountAsync(User, Password, DemoAccount);
            CustomerAccountInfo[] AccountInfor = await GetAccount;
            foreach(CustomerAccountInfo a in AccountInfor)
            {
                AccountView.Add(a);
            }
        }
        catch (Exception ex)
        {
            AccountView.Error = ex.ToString();
            return BadRequest(ex.ToString());
        }

It seem like i need to config/ add endpoint configuration at the line

ServicesSoapClient client = new ServicesSoapClient();

but i can't find where the connected services save the endpoint configuration . WCF reference

So any help to config endpoint is welcome :D

1 Answer 1

0

Find out the string endpointConfigurationName listed on web.config file. My string endpointConfigurationName in web.config is look like

<client>
      <endpoint address="https://***" binding="basicHttpBinding" bindingConfiguration="ServicesSoap" contract="AlineTest.ServicesSoap" name="ServicesSoap" />
      <endpoint address="https://***" binding="customBinding" bindingConfiguration="ServicesSoap12" contract="AlineTest.ServicesSoap" name="ServicesSoap12" />
      <endpoint address="https://***" binding="basicHttpBinding" bindingConfiguration="SubscriberManagementSoap" contract="Mytv.SubscriberManagementSoap" name="SubscriberManagementSoap" />
      <endpoint address="https://***" binding="customBinding" bindingConfiguration="SubscriberManagementSoap12" contract="Mytv.SubscriberManagementSoap" name="SubscriberManagementSoap12" />
    </client>

so i added string "ServicesSoap" to my ServicesSoapClient client = new ServicesSoapClient(); and it work

  try
        {
            ServicesSoapClient client = new ServicesSoapClient("ServicesSoap");
            Task<CustomerAccountInfo[]> GetAccount = client.GetAccountAsync(User, Password, DemoAccount);
            CustomerAccountInfo[] AccountInfor = await GetAccount;
            foreach(CustomerAccountInfo a in AccountInfor)
            {
                AccountView.Add(a);
            }
        }
        catch (Exception ex)
        {
            AccountView.Error = ex.ToString();
            return BadRequest(ex.ToString());
        }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.