From edf2f9f0119f2f1473384b4eeea69aca72603387 Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Sun, 14 Aug 2011 18:25:32 +0200 Subject: [PATCH] [Doc] Added header tutorial --- Resources/doc/index.rst | 1 + Resources/doc/tutorial/header.rst | 32 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 Resources/doc/tutorial/header.rst diff --git a/Resources/doc/index.rst b/Resources/doc/index.rst index 07ac795..f7ca83b 100644 --- a/Resources/doc/index.rst +++ b/Resources/doc/index.rst @@ -23,5 +23,6 @@ Tutorial tutorial/array tutorial/complex_type + tutorial/header .. _`ckWebServicePlugin`: http://www.symfony-project.org/plugins/ckWebServicePlugin \ No newline at end of file diff --git a/Resources/doc/tutorial/header.rst b/Resources/doc/tutorial/header.rst new file mode 100644 index 0000000..b71bd89 --- /dev/null +++ b/Resources/doc/tutorial/header.rst @@ -0,0 +1,32 @@ +Header +====== + +Controller +---------- + +.. code-block:: php + + namespace My\App\Controller; + + use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap; + use BeSimple\SoapBundle\Soap\SoapResponse; + use Symfony\Component\DependencyInjection\ContainerAware; + + class DemoController extends ContainerAware + { + /** + * @Soap\Method("hello") + * @Soap\Header("api_key", phpType = "string") + * @Soap\Param("names", phpType = "string[]") + * @Soap\Result(phpType = "string") + */ + public function helloAction(array $names) + { + $soapHeaders = $this->container->get('request')->getSoapHeaders(); + if (!$soapHeaders->has('api_key') || '1234' !== $soapHeaders->get('api_key')->getData()) { + throw new \SoapFault("INVALID_API_KEY", "The api_key is invalid."); + } + + return new SoapResponse("Hello ".implode(', ', $names)); + } + } \ No newline at end of file