![]() |
|
ckWebServicePlugin - 1.0.0WebService API Plugin. |
|
![]() |
65
users
Sign-in
to change your status |
This plugin exposes your actions as a webservice api. |
| Name | Status | |
|---|---|---|
|
|
lead | ed.bew <<ta>> lrek-naitsirhc |
Copyright (c) 2008 Christian Kerl
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
| Version | License | API | Released |
|---|---|---|---|
| 4.0.0stable | MIT license | 4.0.0stable | 18/06/2010 |
| Version | License | API | Released |
|---|---|---|---|
| 4.0.0stable | MIT license | 4.0.0stable | 18/06/2010 |
| Version | License | API | Released |
|---|---|---|---|
| 3.1.0stable | MIT license | 3.1.0stable | 09/01/2010 |
| 3.0.0stable | MIT license | 3.0.0stable | 17/01/2009 |
| Version | License | API | Released |
|---|---|---|---|
| 2.3.0stable | MIT license | 2.3.0stable | 08/08/2009 |
| 2.2.2stable | MIT license | 2.2.2stable | 16/01/2009 |
| 2.2.1stable | MIT license | 2.2.1stable | 20/11/2008 |
| 2.2.0stable | MIT license | 2.2.0stable | 20/11/2008 |
| 2.1.0stable | MIT license | 2.1.0stable | 19/08/2008 |
| 2.0.0devel | MIT license | 2.0.0devel | 19/07/2008 |
| Version | License | API | Released |
|---|---|---|---|
| 1.5.0stable | MIT license | 1.5.0stable | 19/08/2008 |
| 1.4.1stable | MIT license | 1.4.1stable | 19/07/2008 |
| 1.4.0stable | MIT license | 1.4.0stable | 17/06/2008 |
| 1.2.0stable | MIT license | 1.2.0stable | 10/04/2008 |
| 1.1.3stable | MIT license | 1.1.3stable | 29/03/2008 |
| 1.0.0stable | MIT license | 1.0.0stable | 12/03/2008 |
Array
Array
Array
The ckWebServicePlugin is a symfony plugin that let you expose your modules and actions as a webservice.
The Plugin is based on the standard PHP SOAP module, see http://de.php.net/manual/en/ref.soap.php
It offers automatic generation of .wsdl files from your source code.
Install the plugin
download the attached archive and put the ckWebServicePlugin into your /plugins folder
Configure the application in your app.yml
# your soap enviroment
soap:
# enable the `ckSoapParameterFilter`
enable_soap_parameter: on
ck_web_service_plugin:
# the location of your .wsdl file
wsdl: http://localhost/myWebService.wsdl
# the class that will be registered as handler for webservice requests
handler: ckSoapHandler
# set the persistence mode
persist: %SOAP_PERSISTENCE_SESSION%
# set the method every action has to implement to get the result of the action
result_callback: getSoapResult
# the options array, which is passed to the `SoapServer` constructor
options:
encoding: utf-8
soap_version: %SOAP_1_2%
You only have to configure wsdl, options and set enable_soap_parameter to on, if you want to use the standard settings shown above.
Enable the controller in your factories.yml
# your soap enviroment
soap:
controller:
class: ckWebServiceController
Enable the ckSoapParameterFilter in your filters.yml
soap_parameter:
class: ckSoapParameterFilter
param:
# `app_enable_soap_parameter` has to be set to `on` so the filter is only enabled in soap mode
condition: %APP_ENABLE_SOAP_PARAMETER%
Clear your cache
symfony cc
Add @ws-enable-tag to the comment block
Also the method has no parameters add @param-tags for each parameter you want to use
Add a @return-tag for the return type of the method
The following example action should illustrate the use
class fooActions extends sfActions
{
/**
* Method to get the result, when in soap mode
*/
public function getSoapResult()
{
return $this->result;
}
/**
* Executes index action
*
* @ws-enable
* @param string $test A string parameter
*
* @return string A string
*/
public function executeIndex()
{
$this->result = 'Parameter $test='.$this->request->getParameter('test');
//this is optional
return sfView::NONE;
}
/**
* A method which will not be exposed in the wsdl.
*
* @param string $test A string parameter
*
* @return string A string
*/
public function executeBar()
{
}
}
Execute the pake task, be sure the env_name is the same you used in the configuration
symfony build-wsdl app_name env_name [[debug](controller_name]) webservice_name webservice_base_url
Clear your cache
symfony cc
This will add a .wsdl file to your /web folder, and add configuration on how to map the soap to request parameters to each module.yml, which exposes at least one method
The names of the methods in the generated .wsdl file will follow the scheme module_Action
This task will also create a new controller in your /web folder
Complex Types are also supported by the wsdl-build-task, but the classes have to be in the /lib or /apps/my_app/lib folder
To use your own .wsdl or to use more descriptive method names, you should implement your own handler class and set the handler config parameter in your app.yml, see the following example:
class mySoapHandler
{
public function descriptiveFoo($foo, $bar)
{
return sfContext::getInstance()->getController()->invokeSoapEnabledAction('fooModule', 'index', array($foo, $bar));
}
}
If you have edited the modules.yml of your fooModule the mapping to request parameters will still be available, otherwise you will find them in the array returned by:
$request->getParameter('param', 'ckWebServicePlugin');
Browse the source to better understand what's going on inside :)
You may write me an email to: christian-kerl [web dot de
