| 1 | = Zarejestruj dokument w dzienniku = |
| 2 | |
| 3 | |
| 4 | ''' Definicja parametrów: ''' |
| 5 | {{{ |
| 6 | #!php |
| 7 | <?php |
| 8 | |
| 9 | /** |
| 10 | * Dodaje dokument do dziennika |
| 11 | * |
| 12 | * @param String data (tablica danych) |
| 13 | * @param documentId Int - identyfikator dokumentu (documents:doc_id) |
| 14 | * @param registerId Int - identyfikator dziennika (registers:reg_id) |
| 15 | * |
| 16 | * @return String - numer ewidencyjny jeśli sukces, 0 w razie niepowodzenia |
| 17 | * |
| 18 | * @throws Exception - SoapFault |
| 19 | */ |
| 20 | String RegisterDocument(String data, Int documentId, Int registerId) |
| 21 | |
| 22 | ?> |
| 23 | }}} |
| 24 | |
| 25 | ''' Przykłady wywołań: ''' |
| 26 | {{{ |
| 27 | #!php |
| 28 | |
| 29 | // Plik MyService.php umieszczony w apps/edokumenty. |
| 30 | // MyService.php |
| 31 | <?php |
| 32 | |
| 33 | define('EDOK_API_LOGIN', 'developer'); |
| 34 | define('EDOK_API_PASSWORD', 'developer'); |
| 35 | define('DEFAULT_ENTITY_SYMBOL', 'demo'); |
| 36 | |
| 37 | require_once('./classes/eDokumentyApi/EDokApiClient.inc'); |
| 38 | |
| 39 | $options = array( |
| 40 | 'location' => 'http://{host}:{port}/eDokumentyApi.php', |
| 41 | "uri" => "eDokumentyAPI", |
| 42 | 'encoding'=>'UTF-8' |
| 43 | ); |
| 44 | |
| 45 | $client = new EDokApiClient(NULL, $options); |
| 46 | $client->setUser(EDOK_API_LOGIN); |
| 47 | $client->setPass(md5(EDOK_API_PASSWORD)); |
| 48 | $header = new SoapHeader('eDokumentyAPI', 'entity_symbol', DEFAULT_ENTITY_SYMBOL); |
| 49 | $client->__setSoapHeaders($header); |
| 50 | |
| 51 | $data = array('in_dat' => date('Y-m-d'); |
| 52 | $registerId = 2; |
| 53 | $documentId = 100; |
| 54 | |
| 55 | try { |
| 56 | $out = $client->registerDocument($data, $registerId, $documentId); |
| 57 | var_dump($out); |
| 58 | } catch(SoapFault $fault) { |
| 59 | var_dump($fault); |
| 60 | |
| 61 | if ($fault->faultcode < 100) { |
| 62 | trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | ?> |
| 67 | }}} |