Estoy intentando listar un cliente con WCF y me aparece este error y he mirado que antes muchas personas lo han hecho así, talvés sea de configuaración.
Mensaje de error:
[![introducir la descripción de la imagen aquí][1]][1]
Y este es el código:
public List<Datos.cliente> listarClientesGeneral()
{
using (TallerRefuerzoEntities conexto = new TallerRefuerzoEntities())
{
return conexto.cliente.ToList();
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
namespace WcfHotel
{
[ServiceContract]
public interface IService1
{
[OperationContract]
List<Datos.cliente> listarClientesGeneral();
}
}
En el web.config tengo esto:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<directoryBrowse enabled="true" />
</system.webServer>
<connectionStrings>
<add name="TallerRefuerzoEntities" connectionString="metadata=res://*/Datos.Model1.csdl|res://*/Datos.Model1.ssdl|res://*/Datos.Model1.msl;provider=System.Data.SqlClient;provider connection string="data source=DORADO-PC;initial catalog=TallerRefuerzo;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
Este es mi error al invocar en el cliente de prueba wcf y en la parte de abajo colocaré el error al subirlo al iis, tal vez sea de utilidad:
No se pudo invocar el servicio. Causas posibles: el servicio está sin conexión o inaccesible. la configuración del cliente no coincide con el proxy; el proxy existente no es válido. Consulte el seguimiento de la pila para obtener más información. Para intentar la recuperación, inicie un nuevo proxy, restablezca la configuración predeterminada o actualice el servicio.
Error al recibir la respuesta HTTP a http://localhost:49612/Service1.svc. Puede deberse a que el enlace del extremo de servicio no usa el protocolo HTTP. También puede deberse a que el servidor anula un contexto de solicitud HTTP (posiblemente por el cierre del servicio). Consulte los registros del servidor para obtener más información.
Server stack trace: en System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason) en System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) en System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout) en System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout) en System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) en System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) en System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]: en System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) en System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) en IService1.Listar() en Service1Client.Listar()
Inner Exception: Se ha terminado la conexión: Error inesperado de recepción. en System.Net.HttpWebRequest.GetResponse() en System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
Inner Exception: No se puede escribir datos de en la conexión de transporte: Se ha forzado la interrupción de una conexión existente por el host remoto. en System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) en System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size) en System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
Inner Exception: Se ha forzado la interrupción de una conexión existente por el host remoto en System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) en System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)