I'm having a problem with my WCF Service, the methods itself collect the right data and return the correct datatypes however I always get the same error regardless of which bindingtype I use for my endpoints. I've tried TCP, HTTP and NamedPipe. The general error at the top is the following:
Failed to invoke the service. Possible causes: The service is offline or inaccessible; the client-side configuration does not match the proxy; the existing proxy is invalid. Refer to the stack trace for more detail. You can try to recover by starting a new proxy, restoring to default configuration, or refreshing the service.
The one posted is from the HTTP binding.
An error occurred while receiving the HTTP response to http://localhost:8732/ClubService/. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ClientReliableChannelBinder`1.RequestClientReliableChannelBinder`1.OnRequest(TRequestChannel channel, Message message, TimeSpan timeout, MaskingMode maskingMode)
at System.ServiceModel.Channels.ClientReliableChannelBinder`1.Request(Message message, TimeSpan timeout, MaskingMode maskingMode)
at System.ServiceModel.Channels.ClientReliableChannelBinder`1.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Security.SecuritySessionClientSettings`1.SecurityRequestSessionChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at IAndereBoekenService.BoekBeschikbaar(String isbn)
at AndereBoekenServiceClient.BoekBeschikbaar(String isbn)
Inner Exception:
The underlying connection was closed: An unexpected error occurred on a receive.
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
Inner Exception:
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
Inner Exception:
An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
App.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="ClubServiceLibrary.ClubService">
<host>
<baseAddresses>
<add baseAddress="net.pipe://localhost/ClubService" />
<add baseAddress ="net.tcp://localhost/ClubService" />
<add baseAddress="http://localhost:8732/ClubService/" />
</baseAddresses>
</host>
<endpoint name ="namedPipeClub"
binding="netNamedPipeBinding"
contract="ClubServiceLibrary.IClubServiceLibrary" />
<endpoint name="namedPipeClubMEX"
address="mex"
binding="mexNamedPipeBinding"
contract="IMetadataExchange" />
<endpoint name ="tcpClub"
binding="netTcpBinding"
contract="ClubServiceLibrary.IClubServiceLibrary" />
<endpoint name="tcpClubMEX"
address="mex"
binding="mexTcpBinding"
contract="IMetadataExchange" />
<endpoint binding="wsHttpBinding"
name="httpClub"
contract="ClubServiceLibrary.IClubServiceLibrary" />
<endpoint address="mex"
binding="mexHttpBinding"
name="httpClubMEX"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
I'm getting my data out of a dictionary which is filled up with dummy data in another class called "DummyData", this does get filled with data.
private static Dictionary<int, Club> clubsValue;
public static Dictionary<int, Club> Clubs
{
get { return clubsValue; }
}
In my ClubService class I do the following:
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
public class ClubService : IClubService
{
public List<Club> GetClubByName(string search)
{
var searchToLower = search.ToLower();
List<Club> test = DummyData.Clubs.Values.Where(b => b.Titel.ToLower().Contains(searchToLower)).ToList();
return test;
}
}
My IClubInterface looks like this:
[ServiceContract(Namespace = "http://club.com/clubservice")]
interface IClubService
{
[OperationContract]
List<Club> GetClubByName(string search);
}
So when debugging all the data is in the list and I return the correct list.. however every single time I get this error messages and I have no idea how to resolve this.