1 | |
---|
2 | |
---|
3 | eGroupWare XML-RPC/SOAP Methodology |
---|
4 | |
---|
5 | (C) 2001-2004 Miles Lott |
---|
6 | |
---|
7 | milos@groupwhere.org |
---|
8 | |
---|
9 | August 23, 2001 and December 29, 2003 |
---|
10 | |
---|
11 | additions made September 3, 2001. |
---|
12 | |
---|
13 | This document is very preliminary, but describes a working |
---|
14 | system. |
---|
15 | |
---|
16 | 1 System level requests |
---|
17 | |
---|
18 | 1.1 Login and authentication |
---|
19 | |
---|
20 | Authentication for user logins is handled internally no differently |
---|
21 | than for the typical eGroupWare login via web browser. Server |
---|
22 | logins, added for XML-RPC and SOAP, are only slightly different. |
---|
23 | For either protocol, user and server login and authentication |
---|
24 | and subsequent requests are handled by their respective |
---|
25 | server apps, xmlrpc.php and soap.php. A server is identified |
---|
26 | by a custom HTTP header, without which a normal user login |
---|
27 | will be undertaken. |
---|
28 | |
---|
29 | A client or server sends the appropriate XML-RPC or SOAP |
---|
30 | packet containing host, user, and password information to |
---|
31 | the phpgw server. The server then assigns a sessionid and |
---|
32 | key, which is returned to the client in the appropriate |
---|
33 | format. |
---|
34 | |
---|
35 | Our current method for authenticating requests after successful |
---|
36 | login is via the Authorization: Basic HTTP header to be |
---|
37 | sent by the client or requesting server. The format of this |
---|
38 | header is a base64 encoding of the assigned sessionid and |
---|
39 | kp3 variables, seperated by a ':'. |
---|
40 | |
---|
41 | Further security may be obtained by using SSL on the client |
---|
42 | and server. In the future, we may encrypt/descrypt the data |
---|
43 | on either end, or at least provide this as an option. The |
---|
44 | sessionid and key variables will make this possible, and |
---|
45 | relatively secure. |
---|
46 | |
---|
47 | 1.1.1 system.login |
---|
48 | |
---|
49 | The first request a client will make is the system.login |
---|
50 | method. Here is a sample of a server login packet in XML-RPC: |
---|
51 | |
---|
52 | <?xml version="1.0"?> |
---|
53 | |
---|
54 | <methodCall> |
---|
55 | |
---|
56 | <methodName>system.login</methodName> |
---|
57 | |
---|
58 | <params> |
---|
59 | |
---|
60 | <param> |
---|
61 | |
---|
62 | <value><struct> |
---|
63 | |
---|
64 | <member><name>server_name</name> |
---|
65 | |
---|
66 | <value><string>my.host.name</string></value> |
---|
67 | |
---|
68 | </member> |
---|
69 | |
---|
70 | <member><name>username</name> |
---|
71 | |
---|
72 | <value><string>bubba</string></value> |
---|
73 | |
---|
74 | </member> |
---|
75 | |
---|
76 | <member><name>password</name> |
---|
77 | |
---|
78 | <value><string>gump</string></value> |
---|
79 | |
---|
80 | </member> </struct></value> |
---|
81 | |
---|
82 | </param> |
---|
83 | |
---|
84 | </params> |
---|
85 | |
---|
86 | </methodCall> |
---|
87 | |
---|
88 | And the same in SOAP: |
---|
89 | |
---|
90 | <?xml version="1.0"?> |
---|
91 | |
---|
92 | <SOAP-ENV:Envelope |
---|
93 | |
---|
94 | xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" |
---|
95 | xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema" |
---|
96 | xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" |
---|
97 | xmlns:si="http://soapinterop.org/xsd" |
---|
98 | |
---|
99 | xmlns:ns6="http://soapinterop.org" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> |
---|
100 | |
---|
101 | <SOAP-ENV:Body> <ns6:system_login> |
---|
102 | |
---|
103 | <server_name xsi:type=":string">my.host.name</server_name> |
---|
104 | |
---|
105 | <username xsi:type=":string">bubba</username> |
---|
106 | |
---|
107 | <password xsi:type=":string">gump</password> |
---|
108 | |
---|
109 | </ns6:system_login> |
---|
110 | |
---|
111 | </SOAP-ENV:Body> |
---|
112 | |
---|
113 | </SOAP-ENV:Envelope> |
---|
114 | |
---|
115 | The same style of packet would be required for a user/client |
---|
116 | login. A successful login should yield the following reply: |
---|
117 | |
---|
118 | <methodResponse> |
---|
119 | |
---|
120 | <params> |
---|
121 | |
---|
122 | <param> |
---|
123 | |
---|
124 | <value><struct> |
---|
125 | |
---|
126 | <member><name>sessionid</name> |
---|
127 | |
---|
128 | <value><string>cf5c5534307562fc57915608377db007</string></value> |
---|
129 | |
---|
130 | </member> |
---|
131 | |
---|
132 | <member><name>kp3</name> |
---|
133 | |
---|
134 | <value><string>2fe54daa11c8d52116788aa3f93cb70e</string></value> |
---|
135 | |
---|
136 | </member> |
---|
137 | |
---|
138 | </struct></value> |
---|
139 | |
---|
140 | </param> |
---|
141 | |
---|
142 | </params> |
---|
143 | |
---|
144 | </methodResponse> |
---|
145 | |
---|
146 | And a failed login: |
---|
147 | |
---|
148 | <methodResponse> |
---|
149 | |
---|
150 | <params> |
---|
151 | |
---|
152 | <param> |
---|
153 | |
---|
154 | <value><struct> |
---|
155 | |
---|
156 | <member><name>GOAWAY</name> |
---|
157 | |
---|
158 | <value><string>XOXO</string></value> |
---|
159 | |
---|
160 | </member> |
---|
161 | |
---|
162 | </struct></value> |
---|
163 | |
---|
164 | </param> |
---|
165 | |
---|
166 | </params> |
---|
167 | |
---|
168 | </methodResponse> |
---|
169 | |
---|
170 | eqweqw |
---|
171 | |
---|
172 | 1.1.2 system.logout |
---|
173 | |
---|
174 | Logout: |
---|
175 | |
---|
176 | <?xml version="1.0"?> |
---|
177 | |
---|
178 | <methodCall> |
---|
179 | |
---|
180 | <methodName>system.logout</methodName> |
---|
181 | |
---|
182 | <params> <param> |
---|
183 | |
---|
184 | <value><struct> |
---|
185 | |
---|
186 | <member><name>sessionid</name> |
---|
187 | |
---|
188 | <value><string>ea35cac53d2c12bd05caecd97304478a</string></value> |
---|
189 | |
---|
190 | </member> |
---|
191 | |
---|
192 | <member><name>kp3</name> |
---|
193 | |
---|
194 | <value><string>4f2b256e0da4e7cbbebaac9f1fc8ca4a</string></value> |
---|
195 | |
---|
196 | </member> |
---|
197 | |
---|
198 | </struct></value> |
---|
199 | |
---|
200 | </param> |
---|
201 | |
---|
202 | </params> |
---|
203 | |
---|
204 | </methodCall> |
---|
205 | |
---|
206 | Logout worked: |
---|
207 | |
---|
208 | <methodResponse> |
---|
209 | |
---|
210 | <params> |
---|
211 | |
---|
212 | <param> |
---|
213 | |
---|
214 | <value><struct> |
---|
215 | |
---|
216 | <member><name>GOODBYE</name> |
---|
217 | |
---|
218 | <value><string>XOXO</string></value> |
---|
219 | |
---|
220 | </member> |
---|
221 | |
---|
222 | </struct></value> |
---|
223 | |
---|
224 | </param> |
---|
225 | |
---|
226 | </params> |
---|
227 | |
---|
228 | </methodResponse> |
---|
229 | |
---|
230 | 2 Business layer requests |
---|
231 | |
---|
232 | Once a successful login return packet has been received and |
---|
233 | sessionid/kp3 have been extracted, every subsequent packet |
---|
234 | sent to the egroupware server must be preceded by an Authorization |
---|
235 | header. Here is a sample header: |
---|
236 | |
---|
237 | POST /egroupware/xmlrpc.php HTTP/1.0 |
---|
238 | |
---|
239 | User-Agent: PHP XMLRPC 1.0 |
---|
240 | |
---|
241 | Host: my.local.host |
---|
242 | |
---|
243 | Authorization: Basic ZDgxNDIyZDRkYjg5NDEyNGNiMzZlMDhhZTdlYzAxZmY6NTU3YzkyYjBmNGE4ZDVlOTUzMzI2YmU2OTQyNjM3YjQ= |
---|
244 | |
---|
245 | Content-Type: text/xml |
---|
246 | |
---|
247 | Content-Length: 875 |
---|
248 | |
---|
249 | The longish string is a base64 encoding of the $sessionid |
---|
250 | . ':' . $kp3. For now this is our only supported authentication |
---|
251 | method. Additional methods would probably also affect the |
---|
252 | methodCalls. This is certainly open to discussion. Following |
---|
253 | is a typical request for some contact data: |
---|
254 | |
---|
255 | <?xml version="1.0"?> |
---|
256 | |
---|
257 | <methodCall> |
---|
258 | |
---|
259 | <methodName>addressbook.boaddressbook.read_entries</methodName> |
---|
260 | |
---|
261 | <params> |
---|
262 | |
---|
263 | <param> |
---|
264 | |
---|
265 | <value><struct> |
---|
266 | |
---|
267 | <member><name>start</name> |
---|
268 | |
---|
269 | <value><string>1</string></value> |
---|
270 | |
---|
271 | </member> |
---|
272 | |
---|
273 | <member><name>limit</name> |
---|
274 | |
---|
275 | <value><string>5</string></value> |
---|
276 | |
---|
277 | </member> |
---|
278 | |
---|
279 | <member><name>fields</name> |
---|
280 | |
---|
281 | <value><struct> |
---|
282 | |
---|
283 | <member><name>n_given</name> |
---|
284 | |
---|
285 | <value><string>n_given</string></value> |
---|
286 | |
---|
287 | </member> |
---|
288 | |
---|
289 | <member><name>n_family</name> |
---|
290 | |
---|
291 | <value><string>n_family</string></value> |
---|
292 | |
---|
293 | </member> |
---|
294 | |
---|
295 | </struct></value> |
---|
296 | |
---|
297 | </member> |
---|
298 | |
---|
299 | <member><name>query</name> |
---|
300 | |
---|
301 | <value><string></string></value> |
---|
302 | |
---|
303 | </member> |
---|
304 | |
---|
305 | <member><name>filter</name> |
---|
306 | |
---|
307 | <value><string></string></value> |
---|
308 | |
---|
309 | </member> |
---|
310 | |
---|
311 | <member><name>sort</name> |
---|
312 | |
---|
313 | <value><string></string></value> |
---|
314 | |
---|
315 | </member> |
---|
316 | |
---|
317 | <member><name>order</name> |
---|
318 | |
---|
319 | <value><string></string></value> |
---|
320 | |
---|
321 | </member> |
---|
322 | |
---|
323 | </struct></value> |
---|
324 | |
---|
325 | </param> |
---|
326 | |
---|
327 | </params> |
---|
328 | |
---|
329 | </methodCall> |
---|
330 | |
---|
331 | Successful response: |
---|
332 | |
---|
333 | <?xml version="1.0"?> |
---|
334 | |
---|
335 | <methodResponse> |
---|
336 | |
---|
337 | <params> |
---|
338 | |
---|
339 | <param> |
---|
340 | |
---|
341 | <value><struct> |
---|
342 | |
---|
343 | <member><name>0</name> |
---|
344 | |
---|
345 | <value><struct> |
---|
346 | |
---|
347 | <member><name>id</name> |
---|
348 | |
---|
349 | <value><string>1</string></value> |
---|
350 | |
---|
351 | </member> |
---|
352 | |
---|
353 | <member><name>lid</name> |
---|
354 | |
---|
355 | <value><string></string></value> |
---|
356 | |
---|
357 | </member> |
---|
358 | |
---|
359 | <member><name>tid</name> |
---|
360 | |
---|
361 | <value><string>n</string></value> |
---|
362 | |
---|
363 | </member> |
---|
364 | |
---|
365 | <member><name>owner</name> |
---|
366 | |
---|
367 | <value><string>500</string></value> |
---|
368 | |
---|
369 | </member> |
---|
370 | |
---|
371 | <member><name>access</name> |
---|
372 | |
---|
373 | <value><string>private</string></value> |
---|
374 | |
---|
375 | </member> |
---|
376 | |
---|
377 | <member><name>cat_id</name> |
---|
378 | |
---|
379 | <value><string>1</string></value> |
---|
380 | |
---|
381 | </member> |
---|
382 | |
---|
383 | <member><name>n_given</name> |
---|
384 | |
---|
385 | <value><string>Alan</string></value> |
---|
386 | |
---|
387 | </member> |
---|
388 | |
---|
389 | </struct></value> |
---|
390 | |
---|
391 | </member> |
---|
392 | |
---|
393 | <member><name>1</name> |
---|
394 | |
---|
395 | <value><struct> |
---|
396 | |
---|
397 | <member><name>id</name> |
---|
398 | |
---|
399 | <value><string>2</string></value> |
---|
400 | |
---|
401 | </member> |
---|
402 | |
---|
403 | <member><name>lid</name> |
---|
404 | |
---|
405 | <value><string></string></value> |
---|
406 | |
---|
407 | </member> |
---|
408 | |
---|
409 | <member><name>tid</name> |
---|
410 | |
---|
411 | <value><string>n</string></value> |
---|
412 | |
---|
413 | </member> |
---|
414 | |
---|
415 | <member><name>owner</name> |
---|
416 | |
---|
417 | <value><string>500</string></value> |
---|
418 | |
---|
419 | </member> |
---|
420 | |
---|
421 | <member><name>access</name> |
---|
422 | |
---|
423 | <value><string>private</string></value> |
---|
424 | |
---|
425 | </member> |
---|
426 | |
---|
427 | <member><name>cat_id</name> |
---|
428 | |
---|
429 | <value><string>1</string></value> |
---|
430 | |
---|
431 | </member> |
---|
432 | |
---|
433 | <member><name>n_given</name> |
---|
434 | |
---|
435 | <value><string>Andy</string></value> |
---|
436 | |
---|
437 | </member> |
---|
438 | |
---|
439 | </struct></value> |
---|
440 | |
---|
441 | </member> |
---|
442 | |
---|
443 | ... |
---|
444 | |
---|
445 | Unauthorized access attempt returns: |
---|
446 | |
---|
447 | <methodResponse> |
---|
448 | |
---|
449 | <params> |
---|
450 | |
---|
451 | <param> |
---|
452 | |
---|
453 | <value><string>UNAUTHORIZED</string></value> |
---|
454 | |
---|
455 | </param> |
---|
456 | |
---|
457 | </params> |
---|
458 | |
---|
459 | </methodResponse> |
---|
460 | |
---|
461 | 3 More to come... |
---|
462 | |
---|
463 | Documenting every single call will be difficult, but should |
---|
464 | be done. In leiu of this, please see the class.bo{APPNAME}.inc.php |
---|
465 | files in each application/inc directory in the egroupware |
---|
466 | cvs. In this file will be a list_methods() function, which |
---|
467 | returns the information to the server about input/output |
---|
468 | structure for each call. If the file does not have this |
---|
469 | function, then it is not yet workable via this interface. |
---|
470 | As for the actual functions, they are also in this file. |
---|
471 | Generally, they will all accept associative array input |
---|
472 | and return same, but not always. This code is in flux, have |
---|
473 | fun. |
---|