Tuesday 18 September 2018

Converting Json Data to Xml Data:

Converting Json Data to Xml Data:


 public void xmlSerialize()
        {
            string json = "{'total': 1,  'city': { 'name': 'Zaafaranah, Red Sea, Egypt, EG', 'dest_code': 'D!001031', 'country': 'EG', 'code': 'C!000001'} }";
            System.Xml.XmlDocument xmlDocument = Newtonsoft.Json.JsonConvert.DeserializeXmlNode(json, "city");
            System.Xml.XmlTextWriter xmlTextWriter = new System.Xml.XmlTextWriter("json.xml", null);
            xmlTextWriter.Formatting = System.Xml.Formatting.Indented;
            xmlDocument.Save(xmlTextWriter);
        }

Friday 31 August 2018

How to show the timer Control in mvc using Javascript

How to show the time Control in mvc using Javascript ?

Html code :
     <p id="demo"></p>
Javascript code :
<script>
        var countDownDate = new Date();
        countDownDate.getHours(); // => 9
        countDownDate.setMinutes(countDownDate.getMinutes() + 30); // =>  30 
        countDownDate.getSeconds(); // => 51     
     
            var x = setInterval(function() {
                var now = new Date().getTime();
                var distance = countDownDate - now;
                var minutes = Math.floor((distance % (1000 * 60*60)) / (1000 * 60));
                var seconds = Math.floor((distance % (1000 * 60)) / 1000);
                document.getElementById("demo").innerHTML =  minutes + " : " + seconds;
                if (seconds <= 0 && minutes <= 0) {
                    window.location.href = "../User/User_Login";
                    document.getElementById("demo").innerHTML = "EXPIRED";
                }
            }, 1000);
        }
    </script>

View :
   

Tuesday 28 August 2018

Difference between Web Services and WCF Services?

Web Services vs WCF Services:

Web Services :
  1.   It is introduced in .net 1.0.
  2. ASP.NET Web services send and receive messages by using SOAP over HTTP or HTTPS.
  3. Extension .asmx.
  4. ASP.NET Web services rely on the XmlSerializer in System.XML.Serialization namespace for serialization .
  5. Web service Class  using [WebService] and Web Method using [web method].
  6. Web service can be hosted in IIS only.
  7. Clients for ASP.NET Web services are generated using a command-line tool named WSDL.exe.
  8. Web services don’t support multi-threading.
  9. Performance wise web services are slower than WCF service. 


WCF Services :
  1. It is introduced in .net 3.0 .
  2. WCF services use SOAP by default, but the messages can be in any format, and conveyed by using any transport protocol like HTTP,HTTPs, WS- HTTP, TCP, Named Pipes, MSMQ, P2P(Point to Point) etc.
  3. Extension .svc
  4. WCF using  System.Runtime.Serialization namespace for serialization.
  5. WCF Service Class using [ServiceContract] , Method using [OperationContract] and Properties using [DataMember].
  6. WCF services can be hosted in IIS , WindowsActivation Services(WAS), Managed Windows services or self hosting etc.
  7. WCF uses ServiceModelMetadata Utility tool,svcutil.exe for the same purpose.
  8. WCF services Support multi-threading by using ServiceBehaviour class.
  9. Performance wise WCF services are faster than web service

Web Method Over Loading in Web Service?





  1. Web Method Over Loading in Web Service?

  1.  
  2. [WebService]
  3. public class CustomerService : System.Web.Services.WebService  
  4. {   
  5. [Web Method]
  6.     public int GetAddtionOfNumber(int a,int b)  
  7.     {  
  8.           
  9.         return  a + b;  
  10.     }   
  11. //overload method 
  12. [Web Method]
  13.     public int GetAddtionOfNumber(int a, int b,int c)  
  14.     {  
  15.   
  16.         return a + b + c;  
  17.     }  


This Error Resolving using message name property:

  1. [WebService]
  2. public class CustomerService : System.Web.Services.WebService  
  3. {  
  4.     [WebMethod(MessageName = "AdditionOfTwoNumber")]  
  5.     public int GetAddtionOfNumber(int a,int b)  
  6.     {  
  7.        return a + b;
  8.     }  
  9.     [WebMethod(MessageName = "AdditionOfThreeNumber")]  
  10.     public int GetAddtionOfNumber(int a, int b,int c)  
  11.     { 
  12.         return a + b+c;
  13.     } 
  14. }  







Top Agile Interview Questions & Answers

Top Agile Interview Questions & Answers 1. What is Agile Testing? The first question of agile interview question tests your k...