Wednesday, 14 January 2015

SPDY Protocol - Improve the Speed of web page

SPDY Protocol - Improve the Speed of web page

SPDY (pronounced as speedy) is an application-layer protocol developed at Google for transporting web content.
It is not replacement of HTTP. Just modifies the way HTTP requests and responses are sent over the wire.


Why it is used?
SPDY is used to reduce the load time of web page by multiplexing and compresion.


What are problem with HTTP?
  • HTTP does not have multiplexing HTTP pipelining is susceptible to head of line blocking verbose headers Requirement to use SPDY.
  • SPDY requires the SSL/TLS (with TLS extension ALPN required).



How its works?
When request sent over SPDY, HTTP requests are processed, tokenized, simplified and compressed.
SPDY prioritizing and multiplexing the transfer of web page so that only one connection per client is required.


How it reduced the load time of website?
  • Avoid multiple request by concatenate the JS, CSS files
  • Image spriting
  • Resource inlining
  • It simplified and compress the request.



Who Use/Support the SPDY?
  • Firefox supports SPDY 2 from version 11.
  • Opera browser added support for SPDY as of version 12.10.
  • Internet Explorer 11 added support for SPDY version 3.
  • Google Chrome/Chromium
  • Amazon's Silk browser for the Kindle Fire uses the SPDY protocol to communicate
  • Facebook Makes Itself a Bit More SPDY


See Features of SPDY http://www.chromium.org/spdy/spdy-whitepaper

Tuesday, 13 January 2015

How to create webservice in php with SOAP Technology

How to create webservice in php with SOAP Technology

Here we will learn how to create a SOAP based web service and know how to use a web service created with SOAP.

For creating webservice you must know the basics of following.
What is Web Services
Web Services is Interaction between two machines over a network. It use SOAP, REST, and XML-RPC as a means of communication. A Web service always needs a network for its operation.
Know Difference between WebService and API


What is SOAP
SOAP stands for Simple Object Access Protocol. SOAP is an XML-based protocol for exchanging information between two computers over the internet. It enables you to Remote Procedure Calls (RPC) transported via HTTP.
More About SOAP


Now Follow the following Simple Steps:
1. Donwnload the library File from http://sourceforge.net/projects/nusoap/.
2. Unzip/extract the downloaded zip file.
3. Copy the "lib" folder from unziped folder and past in root folder of your project.
   Suppose your project is myproject:
   Project Location: D:\wamp\www\myproject
   Library Location: D:\wamp\www\myproject\lib
4.Create two files soapServer.php and soapClient.php into myproject folder.
5. Add Following code in soapServer.php
/* Include library file **/ 
require_once ('lib/nusoap.php'); 

/** create the object of SoapServer **/
$serverObj = new soap_server;
$namespace = 'http://localhost/myproject/soapServer.php?wsdl';
$serverObj->configureWSDL('get_messageString', $namespace); 

//register a function that works on server 
$serverObj->register('get_message'); 

// create the function 
function get_message($your_name) 
{ 
return "Hello {$your_name}!"; 
} 

if ( !isset( $HTTP_RAW_POST_DATA ) ){
  $HTTP_RAW_POST_DATA =file_get_contents('php://input' );
} 
// create HTTP listener 
$serverObj->service($HTTP_RAW_POST_DATA);


6. Add Following code in soapClient.php
require_once ('lib/nusoap.php'); 
//Give it value at parameter 
$param = array( 'your_name' => 'Web Technology Experts Notes');

try{
      //Create object that referer a web services 
    $clientObj = new soapclient('http://localhost/myproject/soapServer.php'); 
    //Call a function at server and send parameters too 
    $response = $clientObj->call('get_message',$param); 
    //Process result 
    if($clientObj->fault){ 
      echo "FAULT: Code: ($clientObj->faultcode)"; 
      echo "String: ".$clientObj->faultstring; 
    }else { 
      echo $response; 
      } 
}catch(Exception $e){
    echo $e->getMessage();
}   

7. soapClient.php will use as client whereas soapServer.php will be used as server.