Skip to content
This repository has been archived by the owner on Dec 17, 2020. It is now read-only.
/ GWebService Public archive

Yii Web Service extension based on nusoap

Notifications You must be signed in to change notification settings

hguenot/GWebService

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

GWebService

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.

Installation

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.

Usage

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(
      'service'=>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.

About

Yii Web Service extension based on nusoap

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages