A few differences between asmx .net Web Service and WCF Web Service

5. January 2009 22:08 by Eric in Development, Web Service  //   Comments (0)

Here are some interesting notes we can put down:

1. 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

2. 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.

3. In Web service System.XML.Serialization is supported while in the WCF Service System.RunTime.Serialization is supported

4. WCF Services can be multithreaded via ServiceBehavior class while web service can not be.

5. WCF Services supports different type of bindings like BasicHttpBinding, WSHttpBinding, WSDualHttpBinding etc.while Web services only used soap or xml for this.

6. 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.

 

 

 

 

 

 

 

Difference between int.Parse and Convert.ToInt32

15. November 2007 20:16 by Eric in .net  //   Comments (0)

Have been working as a software developer for quite a while, but never thought about what's the different between int.Parse and Convert.ToInt32 from the type conversion perspective.

In the recent project, I couldn't help noticing some quite interesting difference and quickly put down the following code block to demonstrate it:

string convertToInt = "12";
string nullString = null;
string maxValue = "32222222222222222222222222222222222";
string formatException = "12.32";
 
int parseResult;
 
// It will perfectly convert interger
parseResult= int.Parse(convertToInt);
 
// It will raise Argument Null Exception
parseResult= int.Parse(nullString); 
 
//It willl raise Over Flow Exception 
parseResult= int.Parse(maxValue);
 
//It will raise Format Exception
parseResult= int.Parse(formatException);
 
 
//For Convert.ToInt32
 
//It will perfectly convert integer
parseResult= Convert.ToInt32(convertToInt);
 
//It will ouput as 0 if Null string is there
parseResult= Convert.ToInt32(nullString);
 
//It will raise Over Flow Exception
parseResult= Convert.ToInt32(maxValue);
 
//It will raise Format Exception
parseResult= Convert.ToInt32(formatException);