Worldspan GDS

Guys after a long long period of time and after finishing my college life i think its the time i should share my experience and knowledge with ya, I have gone through some very intelligent systems such as GDS and currently working in the travel industry with a designation of web services programmer feel free to look at my company website and have a look at my booking engine which i have developed My Booking Engine.

Well any one having a relatively small experience in browsing websites must have already understood that the site runs on PHP yes the Personal Hypertext Processor . a pretty small language with a very small library but a wide variety of support and as always open source
take some time out of your schedule to look up the PHP website.

I am working with the webservices exposed by the travelport worldspan GDS , the worldspan is the Global Distribution System which offers the Flight information and Booking API my current employer has paid a hefty sum of $'s to Travelport to gain access to their API and i am here by telling you guys some of the tweaks to get the most optimum result from the travelport WORLDSPAN
 The Technology used by my current Employer is PHP a typical scripting language which is evolving day by day into a hardcore OOL . As a Java Developer it was really difficult for me to get into the scripting methodology so i changed it i have used typical Java Methodology of creating classes and objects for getting into the Java flavour and i was successful also, already two versions of the system are live and running over the web.
for connecting to the worldspan GDS system one requires a SOAP call for calling the the worldspan web service a SORRY for the upcoming developers that currently WORLDSPAN GDS DO NOT SUPPORT WSDL hence we have to call each operation manually.
        For the purpose of authentication the GDS API uses a tc file or a transaction control header
an example of the XML TC file is as follows:


Transaction Control Data
The transaction control data (TC) XML is part of each transaction and allows you to control the underlying provider the message is to be routed to. It is also used for user authentication on transaction level. A TC must be sent with every Xml Pro request message.
Request TC
<tc>
    <iden p="" u="">
    <provider session="" pcc=" >WORLDSPAN</provider>
    <trace></trace>
</iden><tc>





Node
Description
Default (if not specified)
iden
Client identity information for transaction authentication on Xml Pro Server.Attributes:
u = user id
p = password

 mandatory
provider
Name of the provider route. Worldspan will provide this setting.Attributes:
session = identifies session pool or data source of provider
pcc = emulation SID, Mandatory for share environment user

mandatory
trace
Free use trace id for traces to be captured with XXTrace utility
optional



Well dont worry about the technical details its just basic authentication header which could be passed over the normal HTTP or OVER SSL (HTTPS) if your company requires you to do so
let me show you a snippet of the code calling the webservice in php to give you a better understanding of how the things work
Please Be patient and look more towards the highlighted part of the code



require_once("nusoap.php"); //NuSoap library for SOAP access
require_once("class.db_handler.php");

  class request_builder
  {
      var $num_adt;
      var $num_chd;
      var $num_inf;
      var $cab_cla;
      var $origin_code;
      var $dest_code;
      var $search_type;
      var $dep_date;
      var $ret_date;
      var $req_fet;
      var $request_id;
      var $xml_request;
      var $req;
      var $params;
      var $header;
      var $operation;
      var $namespace;
  function request_builder($adt,$chd,$inf,$cabin,$ori,$dest,$srt,$depdate,$retdate,$request_id){
        $this->num_adt=$adt;
        $this->num_chd=$chd;
        $this->num_inf=$inf;
        $this->cab_cla=$cabin;
        $this->origin_code=$ori;
        $this->dest_code=$dest;
        $this->dep_date=$depdate;
        $this->ret_date=$retdate;
        $this->search_type=$srt;
        $this->namespace="xxs";
        $this->header;
        $this->operation="216.113.130.252:8800";
        $this->request_id=$request_id;
      
        $dbhan= new db_handler();
      
        $this->req=$dbhan->get_request($request_id);
        $this->build_request($this->req);
      
      }
  private function build_request($arr){
      //print_r($arr);
         $str="";
          $opt_arr=explode(",",$arr->options);
          $str.="OH";
          foreach($opt_arr as $opt){
          $str.="$opt";
          }
        
          $str.="$this->origin_code12";
          $str.="".$arr->num_alt."";
          $inc_arl_arr=explode(",",$arr->inc_arl);
          $exc_arl_arr=explode(",",$arr->exc_arl);
          if((count($inc_arl_arr)>=1||count($exc_arl_arr)>=1)&&($arr->inc_arl!=''||$arr->exc_arl!=''))
          {
              $str.="";
              if(count($exc_arl_arr)>0&&$arr->exc_arl!='')
              {
                  $str.="";
                  foreach($exc_arl_arr as $exc)
                  {
                      $str.="".$exc."";
                  }
                  $str.="";
              }
              if(count($inc_arl_arr)>0&&$arr->inc_arl!='')
              {
                  $str.="".$arr->arl_opt."";
                  foreach($inc_arl_arr as $inc)
                  {
                      $str.="".$inc."";
                  }
                
              }
            $str.="";
          }
            $rdate=$this->ret_date;
             $ddate=$this->dep_date;
        
        $ptc_arr=explode(",",$arr->ptc);
        $ptc = "$this->num_adt$ptc_arr[0]";
        if($this->num_chd>0){
        $ptc .= "$this->num_chd$ptc_arr[1]";
        }
        if($this->num_inf>0){
        $ptc .= "$this->num_inf$ptc_arr[2]";
        }
        $str.=$ptc;
        $str.="$ddate1200E$this->dest_code";
        if($this->search_type=="RT")
          {
           $str.="$rdate1200E$this->origin_code";
          }
        $str.="";
        $this->header="Worldspan";
       $this->params=$str;
       //echo $str;
      
      }
  private function normalize_date($date) {
        $date = explode('/', $date);
        $date_mon = $date[0];
        $date_dat = $date[1];
        $date_yea = $date[2];
        switch ($date_mon) {
            case 1:
                $date_mon = "JAN";
                break;
            case 2:
                $date_mon = "FEB";
                break;
            case 3:
                $date_mon = "MAR";
                break;
            case 4:
                $date_mon = "APR";
                break;
            case 5:
                $date_mon = "MAY";
                break;
            case 6:
                $date_mon = "JUN";
                break;
            case 7:
                $date_mon = "JUL";
                break;
            case 8:
                $date_mon = "AUG";
                break;
            case 9:
                $date_mon = "SEP";
                break;
            case 10:
                $date_mon = "OCT";
                break;
            case 11:
                $date_mon = "NOV";
                break;
            case 12:
                $date_mon = "DEC";
                break;
        }
        $date = $date_dat.$date_mon;
        return $date;
    }
  public function execute_request()  
    {
       // echo htmlspecialchars($this->params);
      $client= new nusoap_client("https://xmlpro.worldspan.com:443");//instance of a nusoap_client
      if($client->fault)// Check for errors
      { 
          echo $client->faultstring;
      }
      $client->timeout=5000;
      $client->response_timeout=5000;
      $result = $client->call($this->operation, $this->params, $this->namespace, null, $this->header, null, null, null);
      return $client->responseData;// We have just called the Service of the worldspan
    
    }
  }

For Complete code listing archive please check out the Google SVN for cheapfareguru.com