gwebservice Soap client and server based on nusoap library


  1. Installation
  2. Usage
  3. Resources

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 and method could be invoked using URL

  • 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' => ''

// 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

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.


3 0
Yii Version: 1.1
License: LGPL-3.0
Category: Web Service
Developed by: Herve
Created on: Nov 27, 2012
Last updated: 9 years ago

Related Extensions