2011-07-18 22:43:12 +02:00
|
|
|
BeSimpleSoapBundle
|
|
|
|
==================
|
2010-10-03 17:26:14 +02:00
|
|
|
|
2011-07-18 22:43:12 +02:00
|
|
|
The BeSimpleSoapBundle is a Symfony2 bundle to build WSDL and SOAP based web services.
|
2010-10-03 17:26:14 +02:00
|
|
|
It is based on the [ckWebServicePlugin] [1] for symfony.
|
|
|
|
|
2011-04-08 01:19:57 +02:00
|
|
|
Requirements
|
2010-10-08 17:42:42 +02:00
|
|
|
------------
|
|
|
|
|
2011-04-08 01:19:57 +02:00
|
|
|
* Install and enable PHP's `SOAP` extension
|
2011-07-17 10:46:54 +02:00
|
|
|
* Download `Zend\Soap`
|
|
|
|
|
|
|
|
git submodule add http://github.com/zendframework/zf2.git vendor/zend-framework
|
|
|
|
|
|
|
|
* Add `Zend\Soap` library to `app/autoload.php`
|
2011-07-18 22:43:12 +02:00
|
|
|
|
2011-07-17 10:46:54 +02:00
|
|
|
// app/autoload.php
|
|
|
|
$loader->registerNamespaces(array(
|
|
|
|
'Zend\\Soap' => __DIR__.'/../vendor/zend-frameword/library',
|
|
|
|
// your other namespaces
|
|
|
|
));
|
2011-04-08 01:19:57 +02:00
|
|
|
|
|
|
|
QuickStart
|
|
|
|
----------
|
|
|
|
|
2011-07-18 23:31:03 +02:00
|
|
|
* Put BeSimpleSoapBundle in your `vendor/bundles/BeSimple` dir
|
2011-07-17 10:46:54 +02:00
|
|
|
|
2011-07-18 22:43:12 +02:00
|
|
|
git submodule add https://github.com/BeSimple/BeSimpleSoapBundle.git vendor/bundles/BeSimple/SoapBundle
|
2011-07-17 10:46:54 +02:00
|
|
|
|
2011-07-18 22:43:12 +02:00
|
|
|
* Enable BeSimpleSoapBundle in your `app/AppKernel.php`
|
2011-07-14 17:45:03 +02:00
|
|
|
|
2011-07-17 10:46:54 +02:00
|
|
|
// app/AppKernel.php
|
|
|
|
public function registerBundles()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
// ...
|
2011-07-18 22:43:12 +02:00
|
|
|
new new BeSimple\SoapBundle\BeSimpleSoapBundle(),
|
2011-07-17 10:46:54 +02:00
|
|
|
// ...
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-07-18 22:43:12 +02:00
|
|
|
* Register the BeSimple namespace
|
2011-07-17 10:46:54 +02:00
|
|
|
|
|
|
|
// app/autoload.php
|
|
|
|
$loader->registerNamespaces(array(
|
2011-07-18 22:43:12 +02:00
|
|
|
'BeSimple' => __DIR__.'/../vendor/bundles',
|
2011-07-17 10:46:54 +02:00
|
|
|
'Zend\\Soap' => __DIR__.'/../vendor/zend-frameword/library',
|
|
|
|
// your other namespaces
|
|
|
|
));
|
|
|
|
|
2011-07-18 22:43:12 +02:00
|
|
|
* Include the BeSimpleSoapBundle's routing configuration in `app/config/routing.yml` (you can choose the prefix arbitrarily)
|
2011-07-14 17:45:03 +02:00
|
|
|
|
2011-07-18 22:43:12 +02:00
|
|
|
_besimple_soap:
|
|
|
|
resource: "@BeSimpleSoapBundle/Resources/config/routing/webservicecontroller.xml"
|
2011-04-08 01:19:57 +02:00
|
|
|
prefix: /ws
|
2011-07-14 17:45:03 +02:00
|
|
|
|
2011-04-08 01:19:57 +02:00
|
|
|
* Configure your first web service in `app/config/config.yml`
|
2011-07-14 17:45:03 +02:00
|
|
|
|
2011-07-18 22:43:12 +02:00
|
|
|
be_simple_soap:
|
2011-04-08 01:19:57 +02:00
|
|
|
services:
|
2011-07-14 18:39:47 +02:00
|
|
|
DemoApi:
|
2011-07-17 10:46:54 +02:00
|
|
|
namespace: http://mysymfonyapp.com/ws/DemoApi/1.0/
|
2011-04-08 01:19:57 +02:00
|
|
|
binding: rpc-literal
|
|
|
|
resource: "@AcmeDemoBundle/Controller/DemoController.php"
|
|
|
|
resource_type: annotation
|
|
|
|
|
|
|
|
* Annotate your controller methods
|
2011-07-17 10:46:54 +02:00
|
|
|
|
2011-04-08 01:19:57 +02:00
|
|
|
// src/Acme/DemoBundle/Controller/DemoController.php
|
2011-07-21 20:53:49 +02:00
|
|
|
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
|
2011-07-18 22:43:12 +02:00
|
|
|
use BeSimple\SoapBundle\Soap\SoapResponse;
|
2011-07-17 10:46:54 +02:00
|
|
|
|
|
|
|
class DemoController extends Controller
|
2011-04-08 01:19:57 +02:00
|
|
|
{
|
2011-07-17 10:46:54 +02:00
|
|
|
/**
|
2011-07-21 20:53:49 +02:00
|
|
|
* @Soap\Method("Hello")
|
|
|
|
* @Soap\Param("name", phpType = "string")
|
|
|
|
* @Soap\Result(phpType = "string")
|
2011-07-17 10:46:54 +02:00
|
|
|
*/
|
|
|
|
public function helloAction($name)
|
|
|
|
{
|
|
|
|
return new SoapResponse(sprintf('Hello %s!', $name));
|
|
|
|
}
|
2011-04-08 01:19:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
* Open your web service endpoint
|
|
|
|
|
|
|
|
* `http://localhost/app_dev.php/ws/DemoApi` - HTML documentation
|
2011-07-17 10:46:54 +02:00
|
|
|
* `http://localhost/app_dev.php/ws/DemoApi?wsdl` - WSDL file
|
2010-10-08 17:42:42 +02:00
|
|
|
|
|
|
|
Test
|
|
|
|
----
|
|
|
|
|
2011-07-17 10:46:54 +02:00
|
|
|
phpunit -c phpunit.xml.dist
|
2010-10-08 17:42:42 +02:00
|
|
|
|
2011-07-18 22:43:12 +02:00
|
|
|
[1]: http://www.symfony-project.org/plugins/ckWebServicePlugin
|