1
I’m trying to consume a service but it gives the error:
An unhandled Exception of type 'System.Invalidoperationexception' occurred in System.ServiceModel.dll
And the message:
"Could not locate standard endpoint element which refers to the contract 'Servicoempresa.Iempresaservicoremoto' on Client Servicemodel configuration section. This may have occurred due to the lack of a configuration file for your application or because no endpoint element corresponding to this contract could be found in customer element."
This and problem in the app.config?
Client file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="wsHttpBinding_IEmpresaServicoRemoto" />
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8733/Design_Time_Addresses/PontoCerto.ServicoRemoto/EmpresaServicoRemoto/"
binding="wsHttpBinding" bindingConfiguration="wsHttpBinding_IEmpresaServicoRemoto"
contract="PontoCerto.ServicoRemoto.Contratos.IEmpresaServicoRemoto" name="BasicHttpBinding_IEmpresaServicoRemoto" />
</client>
<behaviors>
</behaviors>
</system.serviceModel>
</configuration>"
Arquivo do serviço:
>`<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
<add key="ClientSettingsProvider.ServiceUri" value="" />
</appSettings>
<system.web>
<compilation debug="true" />
<membership defaultProvider="ClientAuthenticationMembershipProvider">
<providers>
<add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
</providers>
</membership>
<roleManager defaultProvider="ClientRoleProvider" enabled="true">
<providers>
<add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
</providers>
</roleManager>
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<extensions>
<behaviorExtensions>
<add name="CustomMessage" type="PontoCerto.ServicoRemoto.Infraestrutura.CustomBehaviorExtensionElement, PontoCerto.ServicoRemoto,
 Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</behaviorExtensions>
</extensions>
<services>
<service name="PontoCerto.ServicoRemoto.Servico.Service1">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/PontoCerto.ServicoRemoto/Service1/" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address="" binding="basicHttpBinding" contract="PontoCerto.ServicoRemoto.Contratos.IService1">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<!-- Metadata Endpoints -->
<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
<service name="PontoCerto.ServicoRemoto.Servicos.EmpresaServicoRemoto">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/PontoCerto.ServicoRemoto/EmpresaServicoRemoto/" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address="" binding="wsHttpBinding"
contract="PontoCerto.ServicoRemoto.Contratos.IEmpresaServicoRemoto"
behaviorConfiguration="ClientEndpointBehavior">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<!-- Metadata Endpoints -->
<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="ClientEndpointBehavior">
<CustomMessage />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Probably yes, has how to post the app.config?
– stderr
@Douglasmendes, I believe your service had an Endpoint Basichttpbinding and you changed it to Wshttpbinding. If so, try removing the Service Reference and adding it again.
– Tobias Mesquita
@Tobymosque I made this change in trying to solve the problem, really the initial project was Basichttpbinding. The funny thing is that using Wcftestclient works normally, but when I try to instantiate the error service this error in the "proxy" class in the client.
– DouglasMendes
Adding as Service Reference? The Service is a WCF application or a WCF library?
– Tobias Mesquita
And as a Service Reference and is a WCF library
– DouglasMendes