HTTP 404 Not Found problem when deploying WCF in IIS 7.0
Introduction
In this tip, i will show how to solve the http 404 not found error at IIS 7.0 with WCF deployment.I was developing a WCF syndication service to be deployed on Windows Azure, I faced a problem that when you deploy the WCF service in IIS 7.0 it doesn't work and gives the following error in the browser: HTTP 404 Not Found.I checked the deployed service it contains the dlls and configuration files. After few minutes i figured out that the problem is in one of IIS features is not enabled which is the WCF activation feature.Steps by Steps Solution
- Open control panel.
- Select programs.
- Select Turn on/Off windows Features.
- Look for Microsoft .Net Framework 3.5.1
- Check WCF HTTP Activation and Non Activation check boxes (BOTH).
- Click ok.
- Now your IIS is configured to host WCF services with HTTP activation and non HTTP Activation requests
Managing your WCF Service Context and State
Introduction
when you create a host for your service,this host manage the context of the service and its states,for this reason,you have to take care how can you configure your host to keep your service under control without any issues regarding the security or performance.One point regarding the Service performance which is the Service Context:did u ask your self if 1000 Clients call your service ? how manay instances will be created from your service ?
To answer this question,you have to know which mode are your setting your service to work with.
1) Per Session Mode :
How to Implement : Mark your service class with this attribute
C# : [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
Answer : 1000 sessions will be created.
2) Per Call Mode :
How to Implement : Mark your service class with this attribute
C# : [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
Answer : Per call the host will create an instance for your service.
This mode give better performance incase the client still opened and not active rather than the prev. mode.
3) Single Mode :
How to Implement : Mark your service class with this attribute
C# : [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
Answer : 1 instance and all clients can share data between them.
Difference between Web Service and WCF Service
Introduction
While taking interviews of .NET developers I often ask this questions. But lots of people don’t know exact difference between this. So, I decided to write a separate article about this.Here are the few differences.
- Web services can be hosted in IIS as well as outside of the IIS. While WCF service can be hosted in IIS, Windows activation service,Self Hosting,WAS and on lots of proctols like Named Pipe,TCP etc.Here lots of people disagree how we can host the web service outside of the IIS but Here is the article for that.http://msdn.microsoft.com/en-us/library/aa529311.aspx.
- In Web Services Web Service attribute will added on the top of class. In WCF there will be a Service Contract attributes will be there. Same way Web Method attribute are added in top of method of Web service while in WCF Service Operation Contract will added on the top method.
- In Web service System.XML.Serialization is supported while in the WCF Service System.RunTime.Serialization is supported.
- WCF Services can be multithreaded via ServiceBehavior class while web service can not be.
- WCF Services supports different type of bindings like BasicHttpBinding, WSHttpBinding, WSDualHttpBinding etc.while Web services only used soap or xml for this.
- Web services are compiled into a class library assembly. A file called the service file is provided that has the extension .asmx and contains an @ WebService directive that identifies the class that contains the code for the service and the assembly in which it is located while in WCF.WCF services can readily be hosted within IIS 5.1 or 6.0, the Windows Process Activation Service (WAS) that is provided as part of IIS 7.0, and within any .NET application. To host a service in IIS 5.1 or 6.0, the service must use HTTP as the communications transport protocol.
No comments:
Post a Comment