/**
  * Add a webmethod
  *
  * @param  lang.XPClass class
  * @param  lang.reflect.Method method
  * @param  string base
  * @throws lang.IllegalArgumentException
  */
 public function addWebmethod($class, $method, $base = '')
 {
     try {
         $webmethod = $method->getAnnotation('webmethod');
     } catch (ElementNotFoundException $e) {
         throw new IllegalArgumentException('Not a webmethod: ' . $method->toString(), $e);
     }
     // Create route from @webmethod annotation
     $route = $this->addRoute(new RestRoute($webmethod['verb'], $base . (isset($webmethod['path']) ? rtrim($webmethod['path'], '/') : ''), $class, $method, isset($webmethod['accepts']) ? (array) $webmethod['accepts'] : NULL, isset($webmethod['returns']) ? (array) $webmethod['returns'] : NULL));
     // Add route parameters using parameter annotations
     foreach ($method->getParameters() as $parameter) {
         $param = $parameter->getName();
         foreach ($parameter->getAnnotations() as $source => $value) {
             $route->addParam($param, new RestParamSource($value ? $value : $param, ParamReader::forName($source)));
         }
     }
 }
 public function string_representation_with_params()
 {
     $r = new RestRoute('GET', '/resource/{id}/{sub}', $this->handler, $this->target, NULL, NULL);
     $r->addParam('id', new RestParamSource('id', ParamReader::forName('path')));
     $r->addParam('sub', new RestParamSource('sub', ParamReader::forName('path')));
     $this->assertEquals('webservices.rest.srv.RestRoute(GET /resource/{id}/{sub} -> void net.xp_framework.unittest.webservices.rest.srv.RestRouteTest::fixtureTarget(@$id: path(\'id\'), @$sub: path(\'sub\')))', $r->toString());
 }