BeSimpleSoap/Resources/doc/reference/configuration.rst
Francis Besset b4da2f727e Added besimple.soap.response service
It is highly recommended not to instantiate BeSimple\SoapBundle\Soap\SoapResponse
but to use the service besimple.soap.response

Before:

    public function helloAction($name)
    {
        return new SoapResponse("Hello ".$name);
    }

After:

    public function helloAction($name)
    {
        return $this
            ->container
            ->get('besimple.soap.response')
            ->setReturnValue("Hello ".$name)
        ;
    }
2011-08-27 22:56:51 +02:00

53 lines
1.4 KiB
ReStructuredText

Configuration
=============
Routing
-------
Include the `BeSimpleSoapBundle`'s routing configuration in your routing file (you can choose the prefix arbitrarily):
.. code-block:: yaml
# app/config/routing.yml
_besimple_soap:
resource: "@BeSimpleSoapBundle/Resources/config/routing/webservicecontroller.xml"
prefix: /ws
Config
------
Configure your first web service in your config file:
.. code-block:: yaml
# app/config/config.yml
be_simple_soap:
services:
DemoApi:
namespace: http://mysymfonyapp.com/ws/DemoApi/1.0/
binding: rpc-literal
resource: "@AcmeDemoBundle/Controller/DemoController.php"
resource_type: annotation
Annotations for Controllers
---------------------------
.. code-block:: php
namespace My\App\Controller;
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
use Symfony\Component\DependencyInjection\ContainerAware;
class DemoController extends ContainerAware
{
/**
* @Soap\Method("hello")
* @Soap\Param("name", phpType = "string")
* @Soap\Result(phpType = "string")
*/
public function helloAction($name)
{
return $this->container->get('besimple.soap.response')->setReturnValue(sprintf('Hello %s!', $name));
}
}