| 1 | = Pobranie definicji rejestru = |
| 2 | |
| 3 | |
| 4 | ''' Definicja parametrów: ''' |
| 5 | {{{ |
| 6 | #!php |
| 7 | <?php |
| 8 | |
| 9 | /** |
| 10 | * Pobiera definicję rejestru |
| 11 | * |
| 12 | * @param string json |
| 13 | * |
| 14 | * @access public |
| 15 | * @return string json |
| 16 | */ |
| 17 | public function getRegister($params) { |
| 18 | |
| 19 | ?> |
| 20 | }}} |
| 21 | |
| 22 | ''' Przykłady wywołań: ''' |
| 23 | {{{ |
| 24 | #!php |
| 25 | |
| 26 | // Plik MyService.php umieszczony w apps/edokumenty. |
| 27 | // MyService.php |
| 28 | <?php |
| 29 | |
| 30 | define('EDOK_API_LOGIN', 'developer'); |
| 31 | define('EDOK_API_PASSWORD', 'developer'); |
| 32 | define('DEFAULT_ENTITY_SYMBOL', 'demo'); |
| 33 | |
| 34 | require_once('./classes/eDokumentyApi/EDokApiClient.inc'); |
| 35 | |
| 36 | $options = array( |
| 37 | 'location' => 'http://{host}:{port}/eDokumentyApi.php', |
| 38 | "uri" => "eDokumentyAPI", |
| 39 | 'encoding'=>'UTF-8' |
| 40 | ); |
| 41 | |
| 42 | $client = new EDokApiClient(NULL, $options); |
| 43 | $client->setUser(EDOK_API_LOGIN); |
| 44 | $client->setPass(md5(EDOK_API_PASSWORD)); |
| 45 | $header = new SoapHeader('eDokumentyAPI', 'entity_symbol', DEFAULT_ENTITY_SYMBOL); |
| 46 | $client->__setSoapHeaders($header); |
| 47 | |
| 48 | try { |
| 49 | $data = array( |
| 50 | 'name__' => 'oskar_reg_2', |
| 51 | ); |
| 52 | $reg_data = $client->getRegister($data); |
| 53 | var_dump($reg_data); |
| 54 | |
| 55 | } catch(SoapFault $fault) { |
| 56 | |
| 57 | var_dump($fault); |
| 58 | |
| 59 | if ($fault->faultcode < 100) { |
| 60 | trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | try { |
| 65 | $data = array( |
| 66 | 'name__' => 'oskar_reg_2', |
| 67 | ); |
| 68 | $max_date = $client->getMaxDateForRegister($data); |
| 69 | var_dump($max_date); |
| 70 | |
| 71 | } catch(SoapFault $fault) { |
| 72 | |
| 73 | var_dump($fault); |
| 74 | |
| 75 | if ($fault->faultcode < 100) { |
| 76 | trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR); |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | try { |
| 81 | $data = array(); |
| 82 | for ($i = 100; $i--;) { |
| 83 | $data[] = array( |
| 84 | 'dscrpt' => 'r '.date('d H:m:s').' '.$i, |
| 85 | 'reg_id' => $reg_data['id____'], |
| 86 | 'assdasd' => $i, |
| 87 | 'e3e3e' => '12345', |
| 88 | 'r4r4r4' => md5($i.'aaaa'), |
| 89 | ); |
| 90 | } |
| 91 | // może być json |
| 92 | // $data = json_encode($data); |
| 93 | $result = $client->addRegisterEntries($reg_data['id____'], $data); |
| 94 | var_dump($result); |
| 95 | |
| 96 | } catch(SoapFault $fault) { |
| 97 | |
| 98 | var_dump($fault); |
| 99 | |
| 100 | if ($fault->faultcode < 100) { |
| 101 | trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR); |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | try { |
| 106 | $data = array( |
| 107 | 'name__' => 'oskar_reg_2', |
| 108 | ); |
| 109 | $max_date = $client->getMaxDateForRegister($data); |
| 110 | var_dump($max_date); |
| 111 | |
| 112 | } catch(SoapFault $fault) { |
| 113 | |
| 114 | var_dump($fault); |
| 115 | |
| 116 | if ($fault->faultcode < 100) { |
| 117 | trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR); |
| 118 | } |
| 119 | } |
| 120 | ?> |
| 121 | }}} |
| 122 | Powyższy kod udostępniony jest na licencji LGPL [http://www.gnu.org/licenses/lgpl-3.0.txt] |