I am just attempting to create my first Cleaning soap/WSDL-based Web Service in PHP. I made the decision to make use of PEAR's Services_Webservice package. That is what I coded for reason for carrying out some tests (file ws.php):

<?php
ini_set("include_path", '/home/maciek/php:' . ini_get("include_path")  );
ini_set("soap.wsdl_cache_enabled", "0");

require_once 'Services/Webservice.php';

class Box
{
    /**
    * @var int
    */
    public $length = 1;
    /**
    * @var int
    */
    public $width = 2;
    /**
    * @var int
    */
    public $height = 3;
}

class NamedBox extends Box
{
    /**
    * @var string
    */
    public $name = "ABC";
}

$Boxes[1] = new Box();
$Boxes[2] = new Box();

class ws extends Services_Webservice
{
    /**
    * Some data
    */
    private $someData = array (
            'A' => array('B', 'C'),
            'X' => array('Y', 'Z')
            );

    /**
    * Getting some data
    * @param string
    * @return string[]
    */
    public function getsomeData($key)
    {
        $result = array();
        if (isset($this->someData[$key]))
        {
            $result = $this->someData[$key];
        }
        return $result;
    }

    /**
    * Getting Boxes
    * @return Box[]
    */
    public function getBoxes()
    {
        return $Boxes;
    }

    /**
    * Getting NamedBox
    * @return NamedBox
    */
    public function getNamedBox()
    {
        return new NamedBox();
    }   
}

$options = array('uri' => 'ws', 'encoding' => SOAP_ENCODED);

$service = new ws('ws', 'description', $options);

$service->handle();
?>

The following factor I am attempting to do is acquiring the WSDL file. Based on PEAR's documentation, I have to add ?wsdl string to my file's URL. The issue is very strange - my service works only one time! After first service call everything works fine and I am getting WSDL file visible during my browser. But all next (after refreshing the page in internet browser, as well as another internet browser) calls fails... I am getting two error messages:

1) Warning: strpos() [function.strpos]: Offset not found in string in /home/maciek/php/Services/Webservice.php online 518

2) Fatal error: Uncaught exception 'ReflectionException' with message 'Class doesn't exist' in /home/maciek/php/Services/Webservice.php:542 Stack trace: # /home/maciek/php/Services/Webservice.php(542): ReflectionClass->__construct('') #1 /home/maciek/php/Services/Webservice.php(420): Services_Webservice->classMethodsIntoStruct() #2 /home/maciek/php/Services/Webservice.php(212): Services_Webservice->intoStruct() #3 /home/maciek/public_html/noticeboard/boxes/ws.php(82): Services_Webservice->handle() #4 primary tossed in /home/maciek/php/Services/Webservice.php online 542

Looking for what's the reason for the second problem I observed, that in PEAR's code (Webservice.php file) a clear string is putted to ReflectionClass' constructor (although not in first service call!).

I truly do not know how come it takes place. I attempted to place some echo instructions to print useful messages however i did not take action. Probably the most strange factor is the fact that on the couple of hrs after first effective call my service begins working again - and again for just one call. Furthermore, on localhost I don't have trouble... Would you assist me to?

Useful data: Apache 2.2.17, PHP 5.2.12, PEAR Services_Webservice .5.1 (code around 542 line below):

        for ($i = 0; $i < count($params); ++$i) {
            $_class = $params[$i]->getClass();
            $_type  = ($_class) ? $_class->getName() : $param[1][$i];

            $_cleanType = str_replace('[]', '', $_type, $_length);
            $_typens    = str_repeat('ArrayOf', $_length);

            $this->wsdlStruct[$this->classname]['method'][$method->getName()]['var'][$i]['name'] =
                    $params[$i]->getName();
            $this->wsdlStruct[$this->classname]['method'][$method->getName()]['var'][$i]['wsdltype'] =
                    $_typens . $_cleanType;
            $this->wsdlStruct[$this->classname]['method'][$method->getName()]['var'][$i]['type'] =
                    $_cleanType;
            $this->wsdlStruct[$this->classname]['method'][$method->getName()]['var'][$i]['length'] =
                    $_length;
            $this->wsdlStruct[$this->classname]['method'][$method->getName()]['var'][$i]['array'] =
                    ($_length > 0 && in_array($_cleanType, $this->simpleTypes))
                    ? true : false;
            $this->wsdlStruct[$this->classname]['method'][$method->getName()]['var'][$i]['class'] =
                    (!in_array($_cleanType, $this->simpleTypes) && new ReflectionClass($_cleanType))
                    ? true : false; //THAT WAS 542 line
            $this->wsdlStruct[$this->classname]['method'][$method->getName()]['var'][$i]['param'] = true;
        }

Which is 518 line

$docComments_Description = trim(substr($_docComments_Description, strpos($_docComments_Description, '*') + 1, strpos($_docComments_Description, '*', 1) - 1));