Tuesday, February 12, 2013

WCF REST with Request Header

This article demonstrates how to make a call from client to a REST based service with Header in Request

  var binding = new WebHttpBinding();
            binding.Security.Mode = WebHttpSecurityMode.Transport;
            var cf = new WebChannelFactory<SERVICE_TYPE>(binding, new Uri(URL));
            {
                Console.WriteLine("{0}:Creating Channel", System.DateTime.Now.ToString("hh:mm:ss"));
                var proxy = cf.CreateChannel();
  
  using (new OperationContextScope((IClientChannel)proxy))
                {
                    WebOperationContext.Current.OutgoingRequest.Headers.Add("Sample", "SamValue");
                 
                    Console.WriteLine("{0}:Calling Method", System.DateTime.Now.ToString("hh:mm:ss"));
                    proxy.Method(Entity);
                    Console.WriteLine("{0}:Calling Completed in {1} Seconds", System.DateTime.Now.ToString("hh:mm:ss"), System.DateTime.Now.Subtract(le).TotalSeconds);
 }

                }
                cf.Close();
                   Console.ReadLine();

WCF REST

This article demonstrates how to make a call from client to a REST based service

With Https

  var binding = new WebHttpBinding();
            binding.Security.Mode = WebHttpSecurityMode.Transport;
            var cf = new WebChannelFactory<SERVICE_TYPE>(binding, new Uri(URL));
            {
                Console.WriteLine("{0}:Creating Channel", System.DateTime.Now.ToString("hh:mm:ss"));
                var proxy = cf.CreateChannel();
                    Console.WriteLine("{0}:Calling Method", System.DateTime.Now.ToString("hh:mm:ss"));
                    proxy.Method(Entity);
                    Console.WriteLine("{0}:Calling Completed in {1} Seconds", System.DateTime.Now.ToString("hh:mm:ss"), System.DateTime.Now.Subtract(le).TotalSeconds);
                    Console.ReadLine();
                }
                cf.Close();

Tuesday, January 29, 2013

Gmail like Dropdown

Flexbox which looks like a dropdown and accepts JSON object Click here to see demo and download

JSON

Very Easy to Serialize (C# Object to Json) and DeSerialize (Json to C# Object)
please check following links
  • http://blogs.microsoft.co.il/blogs/pini_dayan/archive/2009/03/12/convert-objects-to-json-in-c-using-javascriptserializer.aspx
  • http://www.codeproject.com/Articles/78928/Create-JSON-from-C-using-JSON-Library
  • http://www.codeproject.com/Articles/34730/JSON-and-C-using-Generics-and-Delegates
  • http://json.codeplex.com/
  • http://james.newtonking.com/pages/json-net.aspx

Jquery Html Editor

Very Easy to Implement and Very lightweight Click here to see demo and download

Jquery Checked Checkbox

Using Jquery check whether checkbox is checked and how to get list of checked checkboxes.
  • Method 1. $('#checkBox').attr('checked');
  • Method 2. $('#edit-checkbox-id').is(':checked');
  • Method 3 (list of checked checkboxes).
    $("input[@type=checkbox][@checked]").each( function() { // code } );