Web Service vs WCF Service

This answer is based on an article that no longer exists: Summary of article: “Basically, WCF is a service layer that allows you to build applications that can communicate using a variety of communication mechanisms. With it, you can communicate using Peer to Peer, Named Pipes, Web Services and so on. You can’t compare them … Read more

What is the difference between a WCF Service Application and a WCF Service Library?

A service application includes a website host already setup for you. A service library is a library of services that a host can reference and startup. If you start with a service library (recommended) you can then choose any host you wish (a windows service, IIS/ASP.NET, or even a console application) and you’d just reference … Read more

ContractFilter mismatch at the EndpointDispatcher exception

A “ContractFilter mismatch at the EndpointDispatcher” means the receiver could not process the message because it did not match any of the contracts the receiver has configured for the endpoint which received the message. This can be because: You have different contracts between client and sender. You’re using a different binding between client and sender. … Read more

Increasing the timeout value in a WCF service

Are you referring to the server side or the client side? For a client, you would want to adjust the sendTimeout attribute of a binding element. For a service, you would want to adjust the receiveTimeout attribute of a binding elemnent. <system.serviceModel> <bindings> <netTcpBinding> <binding name=”longTimeoutBinding” receiveTimeout=”00:10:00″ sendTimeout=”00:10:00″> <security mode=”None”/> </binding> </netTcpBinding> </bindings> <services> <service … Read more

How to turn on WCF tracing?

The following configuration taken from MSDN can be applied to enable tracing on your WCF service. <configuration> <system.diagnostics> <sources> <source name=”System.ServiceModel” switchValue=”Information, ActivityTracing” propagateActivity=”true” > <listeners> <add name=”xml”/> </listeners> </source> <source name=”System.ServiceModel.MessageLogging”> <listeners> <add name=”xml”/> </listeners> </source> <source name=”myUserTraceSource” switchValue=”Information, ActivityTracing”> <listeners> <add name=”xml”/> </listeners> </source> </sources> <sharedListeners> <add name=”xml” type=”System.Diagnostics.XmlWriterTraceListener” initializeData=”Error.svclog” /> </sharedListeners> </system.diagnostics> … Read more

How to add a custom HTTP header to every WCF call?

The advantage to this is that it is applied to every call. Create a class that implements IClientMessageInspector. In the BeforeSendRequest method, add your custom header to the outgoing message. It might look something like this: public object BeforeSendRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel) { HttpRequestMessageProperty httpRequestMessage; object httpRequestMessageObject; if (request.Properties.TryGetValue(HttpRequestMessageProperty.Name, out httpRequestMessageObject)) { httpRequestMessage = … Read more

When to use DataContract and DataMember attributes?

Since a lot of programmers were overwhelmed with the [DataContract] and [DataMember] attributes, with .NET 3.5 SP1, Microsoft made the data contract serializer handle all classes – even without any of those attributes – much like the old XML serializer. So as of .NET 3.5 SP1, you don’t have to add data contract or data … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)