Skip to content

Commit 2e78e9a

Browse files
committed
Merge remote-tracking branch 'origin/2.0' into 2.0
2 parents d7143cb + 3607bdf commit 2e78e9a

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

cookbook/web_services/php_soap_extension.rst

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
How to Create a SOAP Web Service in a Symfony2 Controller
55
=========================================================
66

7-
Setting up a controller to act as a SOAP server is simple with a couple
8-
tools. You must, of course, have the `PHP SOAP`_ extension installed.
9-
As the PHP SOAP extension can not currently generate a WSDL, you must either
7+
Setting up a controller to act as a SOAP server is simple with a couple
8+
tools. You must, of course, have the `PHP SOAP`_ extension installed.
9+
As the PHP SOAP extension can not currently generate a WSDL, you must either
1010
create one from scratch or use a 3rd party generator.
1111

1212
.. note::
1313

14-
There are several SOAP server implementations available for use with
15-
PHP. `Zend SOAP`_ and `NuSOAP`_ are two examples. Although we use
16-
the PHP SOAP extension in our examples, the general idea should still
14+
There are several SOAP server implementations available for use with
15+
PHP. `Zend SOAP`_ and `NuSOAP`_ are two examples. Although we use
16+
the PHP SOAP extension in our examples, the general idea should still
1717
be applicable to other implementations.
1818

1919
SOAP works by exposing the methods of a PHP object to an external entity
@@ -22,8 +22,8 @@ which represents the functionality that you'll expose in your SOAP service.
2222
In this case, the SOAP service will allow the client to call a method called
2323
``hello``, which happens to send an email::
2424

25-
// src/Acme/SoapBundle/HelloService.php
26-
namespace Acme\SoapBundle;
25+
// src/Acme/SoapBundle/Services/HelloService.php
26+
namespace Acme\SoapBundle\Services;
2727

2828
class HelloService
2929
{
@@ -58,32 +58,33 @@ a ``HelloService`` object properly:
5858

5959
.. code-block:: yaml
6060
61-
# app/config/config.yml
61+
# app/config/config.yml
6262
services:
6363
hello_service:
64-
class: Acme\DemoBundle\Services\HelloService
64+
class: Acme\SoapBundle\Services\HelloService
6565
arguments: [@mailer]
6666
6767
.. code-block:: xml
6868
6969
<!-- app/config/config.xml -->
7070
<services>
71-
<service id="hello_service" class="Acme\DemoBundle\Services\HelloService">
71+
<service id="hello_service" class="Acme\SoapBundle\Services\HelloService">
7272
<argument type="service" id="mailer"/>
7373
</service>
7474
</services>
7575
76-
Below is an example of a controller that is capable of handling a SOAP
77-
request. If ``indexAction()`` is accessible via the route ``/soap``, then the
76+
Below is an example of a controller that is capable of handling a SOAP
77+
request. If ``indexAction()`` is accessible via the route ``/soap``, then the
7878
WSDL document can be retrieved via ``/soap?wsdl``.
7979

8080
.. code-block:: php
8181
8282
namespace Acme\SoapBundle\Controller;
8383
8484
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
85+
use Symfony\Component\HttpFoundation\Response;
8586
86-
class HelloServiceController extends Controller
87+
class HelloServiceController extends Controller
8788
{
8889
public function indexAction()
8990
{
@@ -101,17 +102,17 @@ WSDL document can be retrieved via ``/soap?wsdl``.
101102
}
102103
}
103104
104-
Take note of the calls to ``ob_start()`` and ``ob_get_clean()``. These
105-
methods control `output buffering`_ which allows you to "trap" the echoed
105+
Take note of the calls to ``ob_start()`` and ``ob_get_clean()``. These
106+
methods control `output buffering`_ which allows you to "trap" the echoed
106107
output of ``$server->handle()``. This is necessary because Symfony expects
107108
your controller to return a ``Response`` object with the output as its "content".
108109
You must also remember to set the "Content-Type" header to "text/xml", as
109-
this is what the client will expect. So, you use ``ob_start()`` to start
110-
buffering the STDOUT and use ``ob_get_clean()`` to dump the echoed output
111-
into the content of the Response and clear the output buffer. Finally, you're
110+
this is what the client will expect. So, you use ``ob_start()`` to start
111+
buffering the STDOUT and use ``ob_get_clean()`` to dump the echoed output
112+
into the content of the Response and clear the output buffer. Finally, you're
112113
ready to return the ``Response``.
113114

114-
Below is an example calling the service using `NuSOAP`_ client. This example
115+
Below is an example calling the service using `NuSOAP`_ client. This example
115116
assumes that the ``indexAction`` in the controller above is accessible via the
116117
route ``/soap``::
117118

0 commit comments

Comments
 (0)