1 | | = [wiki:DeployerGuide Przewodnik wdrożeniowca] > Tytuł - identyczny z linkiem z działu = |
| 1 | = [wiki:DeployerGuide Przewodnik wdrożeniowca] > Utwórz nowy dokument = |
| 2 | |
| 3 | ''' Definicja parametrów: ''' |
| 4 | {{{ |
| 5 | #!php |
| 6 | <?php |
| 7 | |
| 8 | /** |
| 9 | * Tworzy nowy dokument |
| 10 | * |
| 11 | * @param data Array - Tablica z parametrami |
| 12 | * @param data['dscrpt'] String - opis dokumentu |
| 13 | * @param data['dctpid'] Int - typ dokumentu (types_of_documents:dctpid) |
| 14 | * @param data['target'] Int - identyfikator stanowiska (organization_units:orunid) |
| 15 | * @param data['prc_id'] Int - identyfikator sprawy (processes:prc_id) |
| 16 | * @param data['state_'] Int - rodzaj dokumenty (1-wychodzący, 2-przychodzący, 3-wewnętrzny) |
| 17 | * @param data['from_contact_symbol'] String - symbol nadawcy (contacts:symbol) |
| 18 | * @param data['to_contact_symbol'] String - symbol odbiorcy (contacts:symbol) |
| 19 | * |
| 20 | * @return Int - id dokumentu jeśli sukces (documents:doc_id), 0 w razie niepowodzenia |
| 21 | * |
| 22 | * @throws Exception - SoapFault |
| 23 | */ |
| 24 | Int createDocument(Array data) |
| 25 | |
| 26 | ?> |
| 27 | }}} |
| 28 | |
| 29 | ''' Przykłady wywołań: ''' |
| 30 | {{{ |
| 31 | #!php |
| 32 | |
| 33 | // Plik MyService.php umieszczony w apps/edokumenty. |
| 34 | // MyService.php |
| 35 | <?php |
| 36 | |
| 37 | define('EDOK_API_LOGIN', 'developer'); |
| 38 | define('EDOK_API_PASSWORD', 'developer'); |
| 39 | define('DEFAULT_ENTITY_SYMBOL', 'demo'); |
| 40 | |
| 41 | require_once('./classes/eDokumentyApi/EDokApiClient.inc'); |
| 42 | |
| 43 | $options = array( |
| 44 | 'location' => 'http://{host}:{port}/eDokumentyApi.php', |
| 45 | "uri" => "eDokumentyAPI", |
| 46 | 'encoding'=>'UTF-8' |
| 47 | ); |
| 48 | |
| 49 | $client = new EDokApiClient(NULL, $options); |
| 50 | $client->setUser(EDOK_API_LOGIN); |
| 51 | $client->setPass(md5(EDOK_API_PASSWORD)); |
| 52 | $header = new SoapHeader('eDokumentyAPI', 'entity_symbol', DEFAULT_ENTITY_SYMBOL); |
| 53 | $client->__setSoapHeaders($header); |
| 54 | |
| 55 | // Tworzy kontakt |
| 56 | $contid = NULL; |
| 57 | |
| 58 | try { |
| 59 | $data = array( |
| 60 | 'name_1' => 'SOAP TEST'.date('d H:m:s'), |
| 61 | 'name_2' => 'SOAPTEST', |
| 62 | 'nip___' => 1111111111, |
| 63 | 'street' => 'Główna', |
| 64 | 'symbol' => 'FGH99' |
| 65 | ); |
| 66 | $contid = $client->createContact($data); |
| 67 | var_dump($contid); |
| 68 | |
| 69 | } catch(SoapFault $fault) { |
| 70 | |
| 71 | var_dump($fault); |
| 72 | |
| 73 | if ($fault->faultcode < 100) { |
| 74 | trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR); |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | ?> |
| 79 | }}} |