Yii 1.1: gwebservice

Soap client and server based on nusoap library


GWebService is a Web Service extension for YII Framework based on NuSoap library.

It contains :

  • A Web Service Extension :
    • GSoapServer : A component used to publish methods through WSDL definition.
    • GSoapClient : An application component that wraps FTP component.
  • A command tool :
    • wsdl : Generate a custom client using WSDL definition.


GWebService distribution contains 2 folders :

  • command : which contains command line tools. Copy it under commands
  • extension : which contains GWebService extension folder. Copy it under extensions folder.


GWebService extension

We indicate only basic usage. More samples could be found on GWebService extension website.

  • Publish a web service

Web Service publishing is based on PHP doc comment. Document correctly you methode and just insert the @soap tag in any method description to publish it. The other thing to do : define a GSoapServerActionaction in you controller.

class MyController extends CController {
  public function actions() {
    return array(
        'class'    => 'ext.GWebService.GSoapServerAction',
   * @param string $str Your name
   * @return string Hello you !
   * @soap
  public function sayHello($str) {
    return 'Hello ' . $str . '!';

The WSDL could be accessed using http://your.domain.com/index.php?r=my/service and method could be invoked using URL http://your.domain.com/index.php?r=my/service&ws=1.

  • Invoking remote method

You can invoke remote method by instanciatin GSoapClient. Next invoke call method on the created object to invoke remote method.

$client = Yii::createComponent(array(
  'class' => 'ext.GWebService.GSoapClient',
  'wsdlUrl' => 'http://your.domain.com/index.php?r=my/service'
// remote method parameters are passed as an array
$client->call('MyController.sayHello', array('Web Service'));

GWebService command tool

Command line tools generates specific client based on wsdl description by defining methods which map wsdl operation.

protected/yiic wsdl http://your.domain.com/index.php?r=my/service

This will generate class under components folder MyControllerClient having a method sayHello taking a string argument.

class MyControllerClient extends GSoapClient {
    public function sayHello($str) {
        return $this->call('MyController.sayHello', array($str));

Just instanciate new object and call sayHello method.


Total 3 comments

#15430 report it
wwwwww at 2013/11/08 11:28am
I handled it!

Thanks Herve, I handled it with ZEND soap server.

#15397 report it
Herve at 2013/11/06 06:54am
More information

Hi "wwwwww",

Can you send me your code, because without any information it will be difficult to help you.

Thanks. Herve

#15227 report it
wwwwww at 2013/10/19 03:09pm
what is :Array has no namespace!

I used your soap server to create my first yii soap server. I can not see my wsdl. Please help me.

Leave a comment

Please to leave your comment.

Create extension
No downloadable files yet