BeSimpleSoap/README.markdown

98 lines
3.0 KiB
Markdown
Raw Normal View History

2010-10-03 17:26:14 +02:00
WebServiceBundle
================
The WebServiceBundle is a Symfony2 bundle to build WSDL and SOAP based web services.
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
* Download `Zend\Soap`
git submodule add http://github.com/zendframework/zf2.git vendor/zend-framework
* Add `Zend\Soap` library to `app/autoload.php`
// 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
----------
* Put WebServiceBundle in your `vendor/bundles/Bundle` dir
git submodule add https://github.com/BeSimple/BeSimpleSoapBundle.git vendor/bundles/WebServiceBundle
2011-04-08 01:19:57 +02:00
* Enable WebServiceBundle in your `app/AppKernel.php`
2011-07-14 17:45:03 +02:00
// app/AppKernel.php
public function registerBundles()
{
return array(
// ...
new new Bundle\WebServiceBundle\WebServiceBundle(),
// ...
);
}
* Register the Bundle namespace
// app/autoload.php
$loader->registerNamespaces(array(
'Bundle' => __DIR__.'/../vendor/bundles',
'Zend\\Soap' => __DIR__.'/../vendor/zend-frameword/library',
// your other namespaces
));
2011-04-08 01:19:57 +02:00
* Include the WebServiceBundle's routing configuration in `app/config/routing.yml` (you can choose the prefix arbitrarily)
2011-07-14 17:45:03 +02:00
2011-04-08 01:19:57 +02:00
_ws:
resource: "@WebServiceBundle/Resources/config/routing/webservicecontroller.xml"
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-04-08 01:19:57 +02:00
web_service:
services:
DemoApi:
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-04-08 01:19:57 +02:00
// src/Acme/DemoBundle/Controller/DemoController.php
use Bundle\WebServiceBundle\ServiceDefinition\Annotation\Method;
use Bundle\WebServiceBundle\ServiceDefinition\Annotation\Param;
use Bundle\WebServiceBundle\ServiceDefinition\Annotation\Result;
use Bundle\WebServiceBundle\Soap\SoapResponse;
class DemoController extends Controller
2011-04-08 01:19:57 +02:00
{
/**
* @Method("Hello")
* @Param("name", phpType = "string")
* @Result(phpType = "string")
*/
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
* `http://localhost/app_dev.php/ws/DemoApi?wsdl` - WSDL file
2010-10-08 17:42:42 +02:00
Test
----
phpunit -c phpunit.xml.dist
2010-10-08 17:42:42 +02:00
2010-10-03 17:26:14 +02:00
[1]: http://www.symfony-project.org/plugins/ckWebServicePlugin