Zmiany pomiędzy wersją 30 and wersją 31 dla DeployerGuide/Others/eDokumentyApi

Pokaż
Ignoruj:
Data i czas:
02/08/12 14:05:16 (12 years temu)
Autor:
TS (IP: 213.227.67.33)
Komentarz:

--

Legend:

Bez zmian
Dodane
Usunięte
Zmienione
  • DeployerGuide/Others/eDokumentyApi

    v30 v31  
    175175 
    176176 
    177  
    178 {{{ 
    179 #!php 
    180  
    181 // Plik MyService.php umieszczony w apps/edokumenty. 
    182 // MyService.php 
    183 <?php 
    184 // stałe są w confing.inc i są to dane potrzebne do autentykacji usługi 
    185 require_once('./../../framework/lib/util/Translator/Translator.inc'); 
    186 require_once('./config.inc'); 
    187  
    188 // klient SOAP systemu eDokumenty wysyłający nagłówki WSSecurity zmienić na  
    189 // odpowiednią ścieżkę w zależności od lokalizacji pliku MyService.php 
    190 require_once('./classes/eDokumentyApi/EDokApiClient.inc'); 
    191  
    192 // wartość {host}:{port} zmienić na odpowiednią dla serwera 
    193 $ops = array( 
    194     'location' => 'http://{host}:{port}eDokumentyApi.php', 
    195     "uri" => "eDokumentyAPI", 
    196     'encoding'=>'UTF-8' 
    197 ); 
    198  
    199  
    200 // Dodatkowo od wersji 3.3 autentykacja nie wymaga nadpisania klienta Soap. Wystarczy do url z adresem serwisu dodać parametry GET w postaci 
    201 // a1 - login,  
    202 // a2 - hasło,  
    203 // a3 - symbol jednostki 
    204 /*  
    205 $ops = array( 
    206     'location' => 'http://{host}:{port}eDokumentyApi.php?a1='.EDOK_API_LOGIN.'&a2='.md5(md5(EDOK_API_PASSWORD).'_SOAP_eDok_api').'&a3='.DEFAULT_ENTITY_SYMBOL.'', 
    207     "uri" => "eDokumentyAPI", 
    208     'encoding'=>'UTF-8' 
    209 ); 
    210  
    211 // bezpośrednie wywołanie klienta Soap   
    212 $client = new SoapClient(NULL, $ops); 
    213 */ 
    214 $client = new EDokApiClient(null, $ops); 
    215 $client->setUser(EDOK_API_LOGIN); // ten sam co w config.inc 
    216 $client->setPass(md5(EDOK_API_PASSWORD)); // to samo co w config.inc 
    217  
    218 $header = new SoapHeader('eDokumentyAPI', 'entity_symbol', DEFAULT_ENTITY_SYMBOL); 
    219 $client->__setSoapHeaders($header); 
    220  
    221 // Tworzy kontakt 
    222 $contid = NULL; 
    223  
    224 try { 
    225     $data = array( 
    226         'name_1' => 'SOAP TEST'.date('d H:m:s'), 
    227         'name_2' => 'SOAPTEST', 
    228         'nip___' => 1111111111, 
    229         'street' => 'Główna',        
    230         'symbol' => 'FGH99' 
    231     ); 
    232     $contid = $client->createContact($data); 
    233     var_dump($contid); 
    234  
    235 } catch(SoapFault $fault) { 
    236      
    237     var_dump($fault); 
    238      
    239     if ($fault->faultcode < 100) { 
    240         trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR); 
    241     } 
    242 } 
    243  
    244 // Tworzy sprawę 
    245 $prc_id = NULL; 
    246  
    247 try { 
    248     $data = array( 
    249         'dscrpt' => 'SOAP TEST '.date('d H:m:s'), 
    250         'briefcase_symbol' => 'DK.023', 
    251         'orunid' => 49, 
    252         'rspoid' => 54, 
    253         'fxtrid' => 60, 
    254         'prtpid' => 1, 
    255     ); 
    256     $prc_id = $client->createProcess($data); 
    257     var_dump($prc_id); 
    258  
    259 } catch(SoapFault $fault) { 
    260      
    261     var_dump($fault); 
    262      
    263     if ($fault->faultcode < 100) { 
    264         trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR); 
    265     } 
    266 } 
    267  
    268 // tworzy dokument w sprawie 
    269 if ($prc_id) { 
    270      
    271     $doc_id = NULL; 
    272      
    273     try { 
    274         $data = array( 
    275             'dscrpt' => 'SOAP TEST '.date('d H:m:s'), 
    276             'prc_id' => $prc_id, 
    277             'dctpid' => 1, 
    278             'target' => 54, 
    279             'from_contact_symbol' => '12345', 
    280             'to_contact_symbol' => '54321', 
    281         ); 
    282         $doc_id = $client->createDocument($data); 
    283         var_dump($doc_id); 
    284      
    285     } catch(SoapFault $fault) { 
    286          
    287         var_dump($fault); 
    288          
    289         if ($fault->faultcode < 100) { 
    290             trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR); 
    291         } 
    292     } 
    293  
    294     // dodaje załącznik do utworzonego dokumentu 
    295     // o treści Testowy plik i nazwie dokument.txt 
    296     if ($doc_id) { 
    297         try { 
    298             $filePath = './test.pdf'; 
    299             $content = base64_encode(file_get_contents(filePath)); 
    300              
    301             $dd = $client->addAttachmentToDocument($content, basename(filePath), $doc_id); 
    302             var_dump($dd); 
    303          
    304         } catch(SoapFault $fault) { 
    305              
    306             var_dump($fault); 
    307              
    308             if ($fault->faultcode < 100) { 
    309                 trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR); 
    310             } 
    311         } 
    312     } 
    313 } 
    314  
    315 // zwraca dane (tablica) o sprawie wszystko z tabeli processes gdzie prc_id = $prc_id 
    316 try { 
    317  
    318     $data = $client->getProcess($prc_id); 
    319     var_dump($data); 
    320  
    321 } catch(SoapFault $fault) { 
    322      
    323     var_dump($fault); 
    324      
    325     if ($fault->faultcode < 100) { 
    326         trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR); 
    327     } 
    328 } 
    329  
    330 ?> 
    331 }}} 
    332  
    333 W przypadku jeśli chcemy utworzyć własnego klienta SOAP dla innego języka programowania np. JAVA należy skontaktować się z działem oprogramowania celem wyszczególnienia specyfikacji takiego klienta. 
    334  
    335  
    336