Exemplo n.º 1
0
 public function testInvokePhpxmlrpcTestServerExampleEchoesString()
 {
     $client = new Client(self::PHPXMLRPC_TEST_SERVER);
     $request = new Request(self::PHPXMLRPC_TEST_METHOD);
     $string = 'testing 1 2 3';
     $request->addParameter($string);
     $response = $client->invoke($request);
     $this->assertSame($string, $response->getValue());
 }
Exemplo n.º 2
0
 /**
  * Action to show the request form and result of the previously submitted request
  * @return null
  */
 public function indexAction()
 {
     $request = null;
     $response = null;
     $responseString = null;
     $time = null;
     $form = new ClientForm($this->request->getBasePath());
     if ($form->isSubmitted()) {
         try {
             $form->validate();
             $server = $form->getServer();
             $method = $form->getMethod();
             $parameters = $form->getParameters();
             $timer = new Timer();
             $request = $this->getXmlrpcRequest($method, $parameters);
             $client = new Client($server);
             $response = $client->invoke($request);
             $time = $timer->getTime();
         } catch (XmlRpcInvalidResponseException $exception) {
             Zibo::getInstance()->runEvent(Zibo::EVENT_LOG, $exception->getMessage(), $exception->getTraceAsString(), 1);
             $responseString = $exception->getResponseString();
             $previous = $exception->getPrevious();
             if ($previous) {
                 $message = $previous->getMessage();
             } else {
                 $message = $exception->getMessage();
             }
             $error = new ValidationError(self::TRANSLATION_ERROR_RESPONSE, 'Response error: %error%', array('error' => $message));
             $validationException = new ValidationException();
             $validationException->addErrors(ClientForm::FIELD_SERVER, array($error));
             $form->setValidationException($validationException);
         } catch (XmlRpcException $exception) {
             Zibo::getInstance()->runEvent(Zibo::EVENT_LOG, $exception->getMessage(), $exception->getTraceAsString(), 1);
             $error = new ValidationError(self::TRANSLATION_ERROR_CONNECTION, 'Connection error: %error%', array('error' => $exception->getMessage()));
             $validationException = new ValidationException();
             $validationException->addErrors(ClientForm::FIELD_SERVER, array($error));
             $form->setValidationException($validationException);
         } catch (ValidationException $exception) {
             $form->setValidationException($exception);
         }
     }
     $view = new ClientView($form, $request, $response, $responseString, $time);
     $this->response->setView($view);
 }