| 1 | = Pobierz dane o kontrahencie = |
| 2 | |
| 3 | |
| 4 | ''' Definicja parametrów: ''' |
| 5 | {{{ |
| 6 | #!php |
| 7 | <?php |
| 8 | |
| 9 | /** |
| 10 | * Zwraca dane kontaktu wraz z adresem |
| 11 | * |
| 12 | * @param contid Int - Id kontaktu (contacts:contid) |
| 13 | * @param return_json Boolean - określa postać w jakiej zostanie zwrócony wynik (false - tablica; true - JSON), domyślnie false |
| 14 | * |
| 15 | * @return Array - tablica danych kontaktu jeśli sukces, SoapFault w razie niepowodzenia |
| 16 | * |
| 17 | * @throws Exception - SoapFault |
| 18 | */ |
| 19 | Array getContact(Int contid, Boolean return_json = false) |
| 20 | |
| 21 | ?> |
| 22 | }}} |
| 23 | |
| 24 | ''' Przykłady wywołań: ''' |
| 25 | {{{ |
| 26 | #!php |
| 27 | |
| 28 | // Plik MyService.php umieszczony w apps/edokumenty. |
| 29 | // MyService.php |
| 30 | <?php |
| 31 | |
| 32 | define('EDOK_API_LOGIN', 'developer'); |
| 33 | define('EDOK_API_PASSWORD', 'developer'); |
| 34 | define('DEFAULT_ENTITY_SYMBOL', 'demo'); |
| 35 | |
| 36 | require_once('./classes/eDokumentyApi/EDokApiClient.inc'); |
| 37 | |
| 38 | $options = array( |
| 39 | 'location' => 'http://{host}:{port}/eDokumentyApi.php', |
| 40 | "uri" => "eDokumentyAPI", |
| 41 | 'encoding'=>'UTF-8' |
| 42 | ); |
| 43 | |
| 44 | $client = new EDokApiClient(NULL, $options); |
| 45 | $client->setUser(EDOK_API_LOGIN); |
| 46 | $client->setPass(md5(EDOK_API_PASSWORD)); |
| 47 | $header = new SoapHeader('eDokumentyAPI', 'entity_symbol', DEFAULT_ENTITY_SYMBOL); |
| 48 | $client->__setSoapHeaders($header); |
| 49 | |
| 50 | $contid = 123; |
| 51 | $contact = array(); |
| 52 | |
| 53 | try { |
| 54 | $data = array( |
| 55 | 'name_1' => 'SOAP TEST '.date('d H:m:s'), |
| 56 | 'name_2' => 'SOAPTEST', |
| 57 | 'nip___' => 1111111111, |
| 58 | 'street' => 'Główna', |
| 59 | ); |
| 60 | $contact = $client->createContact($contid, false); |
| 61 | var_dump($contact); |
| 62 | |
| 63 | } catch(SoapFault $fault) { |
| 64 | |
| 65 | var_dump($fault); |
| 66 | |
| 67 | if ($fault->faultcode < 100) { |
| 68 | trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | ?> |
| 73 | }}} |