You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Setting up a controller to act as a SOAP server is simple with a couple tools. You must, of course, have the
5
-
`PHP SOAP`_ extension installed. As the PHP SOAP extension can not currently generate a WSDL, you must either
4
+
Setting up a controller to act as a SOAP server is simple with a couple
5
+
tools. You must, of course, have the `PHP SOAP`_ extension installed.
6
+
As the PHP SOAP extension can not currently generate a WSDL, you must either
6
7
create one from scratch or use a 3rd party generator.
7
8
8
9
Here is an example o
@@ -24,10 +25,8 @@ Here is an example o
24
25
25
26
$server->handle();
26
27
27
-
$response->setContent(ob_get_contents());
28
+
$response->setContent(ob_get_clean());
28
29
29
-
ob_clean();
30
-
31
30
return $response;
32
31
}
33
32
@@ -37,13 +36,18 @@ Here is an example o
37
36
}
38
37
}
39
38
40
-
Take note of the calls to ob_start, ob_get_contents, and ob_clean. These methods control `output buffering`_ which allows us to "trap" the echoed output of $server->handle().
41
-
This is necessary because Symfony expects our controller to return a Response object with our output as it's "content".
42
-
You must also remember to set the "Content-Type" header to "text/xml", as this is what the client will expect.
43
-
So, we use ob_start to start buffering the STDOUT and use ob_get_contents to dump the echoed output into the content of our Response.
44
-
Finally, we must call ob_clean to clear our output buffer and return our Response.
39
+
Take note of the calls to ob_start, ob_get_contents, and ob_clean. These
40
+
methods control `output buffering`_ which allows us to "trap" the echoed
41
+
output of $server->handle().
42
+
This is necessary because Symfony expects our controller to return a
43
+
Response object with our output as it's "content". You must also remember
44
+
to set the "Content-Type" header to "text/xml", as this is what the client
45
+
will expect. So, we use ob_start to start buffering the STDOUT and use
46
+
ob_get_clean to dump the echoed output into the content of our Response
47
+
and clear our output buffer. Finally, we're ready to return our Response.
45
48
46
-
Below is an example calling our service using `NuSOAP`_ client. This example assumes indexAction in our controller above is accessible via the route "/soap".
49
+
Below is an example calling our service using `NuSOAP`_ client. This example
50
+
assumes indexAction in our controller above is accessible via the route "/soap".
47
51
48
52
.. code-block:: php
49
53
$client = new soapclient('http://example.com/app.php/soap?wsdl', true);
0 commit comments