Skip to content

Commit 2917057

Browse files
committed
[Doc] Added documentation for SoapClient
1 parent 50ab5a9 commit 2917057

File tree

2 files changed

+151
-1
lines changed

2 files changed

+151
-1
lines changed

src/BeSimple/SoapBundle/Resources/doc/index.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,8 @@ SoapServer
3333
SoapClient
3434
----------
3535

36-
Coming soon.
36+
.. toctree::
37+
:maxdepth: 1
38+
:numbered:
39+
40+
soapclient/configuration
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
Configuration
2+
=============
3+
4+
Minimal client configuration
5+
----------------------------
6+
7+
Configure your first client in your config file:
8+
9+
.. code-block:: yaml
10+
11+
# app/config/config.yml
12+
be_simple_soap:
13+
clients:
14+
DemoApi:
15+
wsdl: http://localhost:8086/app_dev.php/ws/DemoApi?wsdl
16+
17+
18+
Using client
19+
------------
20+
21+
.. code-block:: php
22+
23+
namespace Acme\DemoBundle\Controller;
24+
25+
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
26+
27+
class DemoController extends Controller
28+
{
29+
public function helloAction($name)
30+
{
31+
// The client service name is `besimple.soap.client.demoapi`:
32+
// `besimple.soap.client.`: is the base name of your client
33+
// `demoapi`: is the name specified in your config file converted to lowercase
34+
$client = $this->container->get('besimple.soap.client.demoapi');
35+
36+
// call `hello` method on WebService with the string parameter `$name`
37+
$helloResult = $client->hello($name);
38+
39+
return $this->render('AcmeDemoBundle:Demo:hello.html.twig', array(
40+
'hello' => $helloResult,
41+
));
42+
}
43+
}
44+
45+
Classmap
46+
--------
47+
48+
Configuration
49+
~~~~~~~~~~~~~
50+
51+
.. code-block:: yaml
52+
53+
# app/config/config.yml
54+
be_simple_soap:
55+
clients:
56+
DemoApi:
57+
# ...
58+
classmap:
59+
User: Acme\DemoBundle\Api\UserApi
60+
# add other type_name: classname
61+
62+
UserApi class
63+
~~~~~~~~~~~~~
64+
65+
.. code-block:: php
66+
67+
namespace Acme\DemoBundle\Api;
68+
69+
class UserApi
70+
{
71+
private $username;
72+
73+
private $firstname;
74+
75+
private $lastname;
76+
77+
public function __construct($username)
78+
{
79+
$this->username = $username;
80+
}
81+
82+
public function getFirstname()
83+
{
84+
return $this->firstname;
85+
}
86+
87+
public function getLastname()
88+
{
89+
return $this->lastname;
90+
}
91+
}
92+
93+
Usage
94+
~~~~~
95+
96+
.. code-block:: php
97+
98+
namespace Acme\DemoBundle\Controller;
99+
100+
use Acme\DemoBundle\Api\UserApi;
101+
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
102+
103+
class DemoController extends Controller
104+
{
105+
public function userAction($username)
106+
{
107+
// The client service name is `besimple.soap.client.demoapi`:
108+
// `besimple.soap.client.`: is the base name of your client
109+
// `demoapi`: is the name specified in your config file converted to lowercase
110+
$client = $this->container->get('besimple.soap.client.demoapi');
111+
112+
// call `getUser` method on WebService with an instance of UserApi
113+
// if the `getUserByUsername` method return a `User` type then `$userResult` is an instance of UserApi
114+
$userResult = $client->getUserByUsername($username);
115+
116+
return $this->render('AcmeDemoBundle:Demo:user.html.twig', array(
117+
'user' => $userResult,
118+
));
119+
}
120+
}
121+
122+
Without classmap configuration the `$userResult` is an instance of `stdClass`:
123+
124+
.. code-block:: text
125+
126+
object(stdClass)#5561 (3) {
127+
["username"]=>
128+
string(6) "FooBar"
129+
["firstname"]=>
130+
string(3) "Foo"
131+
["lastname"]=>
132+
string(3) "Bar"
133+
}
134+
135+
With classmap configuration the `$userResult` is an instance of `Acme\DemoBundle\Api\UserApi`:
136+
137+
.. code-block:: text
138+
139+
object(Acme\DemoBundle\Api\UserApi)#208 (3) {
140+
["username":"Acme\DemoBundle\Api\UserApi":private]=>
141+
string(6) "FooBar"
142+
["firstname":"Acme\DemoBundle\Api\UserApi":private]=>
143+
string(3) "Foo"
144+
["lastname":"Acme\DemoBundle\Api\UserApi":private]=>
145+
string(3) "Bar"
146+
}

0 commit comments

Comments
 (0)