Login   Register  
PHP Classes
elePHPant
Icontem

File: WSClientBuilderTemplate.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Basilio Briceņo  >  WS Client Builder  >  WSClientBuilderTemplate.php  >  Download  
File: WSClientBuilderTemplate.php
Role: Auxiliary script
Content type: text/plain
Description: Provides the class template required to generate the client
Class: WS Client Builder
Generate class code for calling a SOAP Web service
Author: By
Last change:
Date: 4 years ago
Size: 1,026 bytes
 

Contents

Class file image Download
<?php
$template 
= <<<EOT
<?php
class 
{$class_name} {

  protected \$service;

  /**
   * Constructs the service
   */
  public function __construct ()
  {
    \$wsdl = "
{$WSDL}";
    try {
      \$this->service = new SoapClient( \$wsdl );
    } catch ( Exception \$e ) {
      return \$e->getMessage();
    }
  }

  /**
   * Provides managment of errors calling the service's methods
   */
  public function __call ( \$name, \$arguments )
  {
    \$result = false;
    \$max_retries = 
{$retries};
    \$retry_count = 0;

    while( !\$result && \$retry_count < \$max_retries ) {
      try {
        \$result = parent::__call( \$name, \$arguments );
      } catch( SoapFault \$fault ) {
        if( \$fault->faultstring != 'Could not connect to host' ) {
          throw \$fault;
        }
      }
      sleep(1);
      \$retry_count++;
    }
    if ( \$retry_count == \$max_retries ) {
      throw new SoapFault( 'Could not connect to host after 
{$retries} attempts' );
    }
    return \$result;
  }

{$methods}}
?>

EOT;
?>