Friday, February 27, 2015

Difference Between Web Service and WCF

Filled under:


The Enterprise Integration Zone is brought to you in partnership with WSO2. Learn more about WSO2's API Management.
Overview
My previous article provided an Introduction to WCF  (Windows Communication Framework). Now we will discuss the differences between Web Services and WCF concepts.

Web Services (ASMX)
Web Services are used to send/receive messages using the Simple Object Access Protocol (SOAP) via HTTP only.

It is available in the namespace “System.Web.Services. WebService Class” with a constructor, methods, prosperities and events.

Code
using System;    
using System.Collections.Generic;    
using System.Web;    
using System.Web.Services;    
    
namespace HelloWorldServices    
{    
    /// <summary>    
    /// Summary description for Service1    
    /// </summary>    
    [WebService(Namespace = "http://tempuri.org/")]    
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]    
    [System.ComponentModel.ToolboxItem(false)]    
    public class Service1 : System.Web.Services.WebService    
    {    
    
        [WebMethod]    
        public string HelloWorld()    
        {    
            return "Hello World";    
        }    
    }    
}  
WCFWCF is used to exchange messages using any format via any transport protocol like HTTP, TCP/IP, MSMQ, Named Pipes and and so on. Its default format is SOAP.
Note: Microsoft Message Queuing (MSMQ) is a messaging queue services developed by Microsoft.
Simple Object Access Protocol (SOAP) is a messaging protocol developed by W3C.

Code: IService1.cs

using System;    
using System.Collections.Generic;    
using System.Linq;    
using System.Runtime.Serialization;    
using System.ServiceModel;    
using System.ServiceModel.Web;    
using System.Text;    
    
namespace HelloWorldWCFService    
{    
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.    
    [ServiceContract]    
    public interface IService1    
    {    
    
        [OperationContract]    
        string GetData(int value);    
    
        [OperationContract]    
        CompositeType GetDataUsingDataContract(CompositeType composite);    
    
        // TODO: Add your service operations here    
    }    
    
    
    // Use a data contract as illustrated in the sample below to add composite types to service operations.    
    [DataContract]    
    public class CompositeType    
    {    
        bool boolValue = true;    
        string stringValue = "Hello ";    
    
        [DataMember]    
        public bool BoolValue    
        {    
            get { return boolValue; }    
            set { boolValue = value; }    
        }    
    
        [DataMember]    
        public string StringValue    
        {    
            get { return stringValue; }    
            set { stringValue = value; }    
        }    
    }    
}    
Service1.svc 

using System;    
using System.Collections.Generic;    
using System.Linq;    
using System.Runtime.Serialization;    
using System.ServiceModel;    
using System.ServiceModel.Web;    
using System.Text;    
    
namespace HelloWorldWCFService    
{    
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.    
    public class Service1 : IService1    
    {    
        public string GetData(int value)    
        {    
            return string.Format("You entered: {0}", value);    
        }    
    
        public CompositeType GetDataUsingDataContract(CompositeType composite)    
        {    
            if (composite == null)    
            {    
                throw new ArgumentNullException("composite");    
            }    
            if (composite.BoolValue)    
            {    
                composite.StringValue += "Suffix";    
            }    
            return composite;    
        }    
    }    
} 
Differences between Web Services and WCF Table
S.NumberFunctionsWCF
1It is available in the namespace "System.Web. Services.WebService Class"It is available in the namespace "System.ServiceModel"
2It is supported hosting only IISIt is supported hosting like IIS, Self Hosting (Console hosting), Windows Activation Services, Windows Services
3It is used for the XML Serializer onlyIt is used to DataContractSerializer only
4It is supported one-way communication and Request-ResponseIt is supported one-way, two-way (Duplex) communication and Request- Response
5It is supported binding like XML 1.0, Message Transmission Optimization Mechanism (MTOM), CustomIt is supported binding like XML 1.0, Message Transmission Optimization Mechanism (MTOM), Binary and Custom
6It is supported transport protocol like HTTP, TCP and customIt is the supported transport protocol like HTTP, TCP, Named Pipes, MSMQ, P2P and custom
7It is supported protocol securityIt is the supported protocol security, transaction and reliable message
Conclusion

This article will help to understand the differences between Web Services and WCF in .NET.

Posted By Unknown11:56 PM

Supersonic Javascript

Filled under:

A few days ago, I gave a talk at the most recent Web Tech Talk meetup hosted by Samsung. The title is Supersonic JavaScript (forgive my little marketing stunt there) and the topic is on changing the way we think about optimizing JavaScript code.
None of the tricks presented there will make your code break the sound barrier. Nevertheless, some of them can serve as the food for thought to provoke our brain to look at the problem in a few different ways. If you want to follow along, check or download the slide deck (before you ask: it was not video recorded).
I discussed four different ideas during the talk.
Short Function. Back in the old days, function calls were expensive. These days, modern JavaScript engines are smart enough and can do self-optimization. For some details on this optimization, read my previous blog post Automatic Inlining in JavaScript Engines and Lazy Parsing in JavaScript Engines. There is no need to outsmart the engine and therefore stick with a concise and readable code.
Fixed Object Shape. This swings in the other direction. How can we help the engine so that it can take the fast path most of the time? For more information, refer to my blog post JavaScript object structure: speed matters.
Profile Guided. Related to the previous point, can we control our own code so that it takes the fast path whenever possible but will still fall back to the slow path everynow and then? What we need is a set of representative data for the benchmark and the profile can be used to tweak the implementation. More details are available in my two other blog posts Profile Guided JavaScript Optimization and Determining Objects in a Set.
Garbage Handling. Producing a lot of object often places a burden on the garbage collector. As an illustration, check out a short video from Jake Archibald describing the situation of using +new Date.
There is no silver bullet to any performance problem. However, like I already mentioned in my Performance Calendar’s article JavaScript Performance Analysis: Keeping the Big Picture, it is important to keep in mind: are we always seeing the big picture or are we trapped into optimizing to the local extreme only?
Now, where’s that TOPGUN application form again…

Posted By Unknown11:53 PM

Video

Filled under:












Posted By Unknown11:35 PM

Online Stores

Filled under:

What Do I Need to Know Before Launching My Online Store?

An e-commerce site builder is a program that lets you build, customize, and run an online store. A complete e-commerce solution will come with the tools to walk you through the entire process: hosting, design, pricing and payment options, marketing tools and reports.
First, consider how much you'll sell. If you anticipate heavy traffic, an e-commerce solution that offers lots of online storage space, inventory, and bandwidth is ideal. Next, decide on the level of customization you'd like. Many e-commerce site builders offer attractive templates ready-to-use, while others come with HTML for more seasoned web designers. Check for must-have features such as payment security and sales reports. Also, be sure to provide enough payment and shipping options for your customers, and look closely at tools such as the ability to create discounts, loyalty programs, or gift-wrap options. Not all website builders will offer the same options, and some may charge for extras. All of these considerations effect the success of your online shop and how you sell online. Finally, go with a program that is easy to use and has a solid customer support team. A well-designed e-commerce builder should be simple yet effective. The less time you have to spend figuring out the program, the more time you'll have to run your business.

E-Commerce 101

Over the past several years, e-commerce has transformed how people buy and sell online. The Internet provides a fast and easy way for people to purchase things without having to visit an actual store. An online store can reach customers anywhere in the world. In fact, online shopping has become so popular that many vendors sell only online with no physical location. E-commerce also facilitates the purchase of digital media such as downloadable music and movies: with no physical product, vendors can boast truly instant delivery. There are many e commerce companies, and it’s important to understand which of the best eCommerce sites let your online shop flourish as you sell online.
Today's top e-commerce site builders take all of these factors into account. Many programs are designed to accommodate the sale of both physical and downloadable products. In addition, online businesses are quickly evolving to face times of economic hardship by offering steeper discounts, flat-rate shipping, loyalty programs, and other perks. Many e-commerce site builders make it easy to run promotions and keep your customers happy. Finally, although the boom in online sales has also opened a potential avenue for fraud and scams, site-builders have managed to stay ahead by offering top-of-the-line site protection and payment security to keep the online marketplace as safe as possible.

The Three S's of E-Commerce

Stick to these three simple S's of e-commerce and you'll be well on your way to launching your online store.
  1. Storage Space:
  2. Some e-commerce site builders put a cap on your sales, so choose one offers you the inventory space and bandwidth to fit your needs. The best ecommerce platform will let your online shop sell online without limitations.
  3. Safety Protocols:
  4. Choose a program that offers fraud protection and Secure Socket Layer (SSL) encryption. This is for the protection of you and your customers. SSL technology makes it possible to send online payments securely and is a must-have on all e-commerce sites.
  5. Site Design:
  6. Your e-commerce solution should have a user-friendly interface. The functions of each tool should be clear and it should be easy to select your desired options. A top-notch site builder will make it easy to build your online store. An extensive FAQ and customer support team can make a world of difference. Also, remember the needs of your customers. Imagine that you're shopping your own online store. Well-designed menus, filters, and sorting options will minimize the amount of time it takes to find a product and purchase it. Consider also the "look" of your site. Many e-commerce site builders offer professionally-designed templates that are both pleasing to the eye and can improve a customer's overall shopping experience. Just like in a physical store, a cluttered and disorganized display will leave customers frustrated and empty-handed, whereas a streamlined and enjoyable buying process will encourage purchasing.

Posted By Unknown1:09 AM