Rest vs Wcf pros and cons [closed]

Rest is a way of doing communication over the internet. It is a very basic process of picking addresses to serve as method locations and returning HTML standard data (javascript, css, html of course). WCF is a .net library used to have two programs talk to each other using SOAP. Which consists of two very … Read more

Closing WCF connection

You have all the necessary information at hand – the resulting Best Practice to use and properly close/abort all your WCF client proxies would be: YourClientProxy clientProxy = new YourClientProxy(); try { .. use your service clientProxy.Close(); } catch(FaultException) { clientProxy.Abort(); } catch(CommunicationException) { clientProxy.Abort(); } catch (TimeoutException) { clientProxy.Abort(); } Catching the FaultException handles … Read more

Custom Tool Warning: Cannot import wsdl:portType

I found the answers in What does this WCF error mean: “Custom tool warning: Cannot import wsdl:portType” help. In my case, I chose unticking the ‘Re-use types’ box and that solved it. Additional Thoughts: SOA, Distributed Objects, & Coupling The ”Service Oriented” Vision implied by a WSDL and the WS-* standards is that the WSDL … Read more

Why is using [DataMember(EmitDefaultValue = false)] not recommended?

The reason is at the bottom of the article that you link to. The short version is: When the EmitDefaultValue is set to false, it is represented in the schema as an annotation specific to Windows Communication Foundation (WCF). There is no interoperable way to represent this information. In particular, the “default” attribute in the … Read more

access HttpContext.Current from WCF Web Service

You can get access to HttpContext.Current by enabling AspNetCompatibility, preferably via configuration: <configuration> <system.serviceModel> <serviceHostingEnvironment aspNetCompatibilityEnabled=”true”/> </system.serviceModel> </configuration> That in turn allows you to get access to the current user: HttpContext.Current.User – which is what you’re after, right? You can even enforce AspNetCompatibility by decorating your service class with an additional attribute: [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)] … Read more

How to add custom soap headers in wcf?

Check out the WCF Extras on Codeplex – it’s an easy extension library for WCF which offers – among other things – custom SOAP headers. Another option is to use WCF message contracts in your WCF service – this also easily allows you to define and set WCF SOAP headers. [MessageContract] public class BankingTransaction { … Read more

what is the global.asax Application_Start equivalent when using WAS in IIS7

I believe AppInitialize() is the method you’re looking for. Here’s an article on using it to initialise Castle Windsor in a WAS hosted WCF service: Castle Windsor and non-HTTP Protocol WCF Services The essence of the article is, instead of using Application_Start() which won’t get called in WAS: protected void Application_Start(object sender, EventArgs e) { … Read more