Čia matote skirtumus tarp pasirinktos versijos ir esamo dokumento.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
lt:xmlcore [2020/07/13 13:22] robertas |
lt:xmlcore [2020/07/21 13:25] robertas |
||
---|---|---|---|
Linija 12: | Linija 12: | ||
- | * **Endpoint URL:** https://directo.gate.ee/xmlcore/demo_lt_153/xmlcore.asp (Jūsų sukurtam servisui pasikeis tik „demo_lt_153“ dalis). | + | * **Endpoint URL:** https://login.directo.ee/xmlcore/demo_lt_153/xmlcore.asp (Jūsų sukurtam servisui pasikeis tik „demo_lt_153“ dalis). |
==== 2.1. Informacijos pasiėmimas iš Directo (OUT) ==== | ==== 2.1. Informacijos pasiėmimas iš Directo (OUT) ==== | ||
Linija 29: | Linija 29: | ||
Užklausos pavyzdys, norint gauti visų prekių sąrašą: | Užklausos pavyzdys, norint gauti visų prekių sąrašą: | ||
- | https://directo.gate.ee/xmlcore/demo_ee/xmlcore.asp?get=1&what=item&key=20DAF3F822B782AF12D1198C23F45604 | + | https://login.directo.ee/xmlcore/demo_ee/xmlcore.asp?get=1&what=item&key=20DAF3F822B782AF12D1198C23F45604 |
Užklausos pavyzdys, norint gauti konkrečios prekės informaciją: | Užklausos pavyzdys, norint gauti konkrečios prekės informaciją: | ||
- | https://directo.gate.ee/xmlcore/demo_ee/xmlcore.asp?get=1&what=item&code=0000&key=20DAF3F822B782AF12D1198C23F45604 | + | https://login.directo.ee/xmlcore/demo_ee/xmlcore.asp?get=1&what=item&code=0000&key=20DAF3F822B782AF12D1198C23F45604 |
- | + | ||
- | **PHP pavyzdys** | + | |
- | <code> | + | |
- | $url = 'https://directo.gate.ee/xmlcore/demo_ee/xmlcore.asp?get=1&what=item&key=20DAF3F822B782AF12D1198C23F45604'; | + | |
- | + | ||
- | $ch = curl_init(); | + | |
- | curl_setopt($ch, CURLOPT_HEADER, 0); | + | |
- | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | + | |
- | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); | + | |
- | curl_setopt($ch, CURLOPT_URL, $url ); | + | |
- | curl_setopt($ch, CURLOPT_POST, 0); | + | |
- | + | ||
- | $result = curl_exec($ch); | + | |
- | + | ||
- | header('Content-Type: text/html; charset=utf-8'); | + | |
- | + | ||
- | print '<textarea cols=80 rows=10>' . $result . '</textarea>'; | + | |
- | + | ||
- | $data = new SimpleXMLElement($result); | + | |
- | + | ||
- | print '<pre>'; | + | |
- | + | ||
- | foreach ($data->items->item as $item) { | + | |
- | print $item['Code'] . chr(9) . '<b>' . $item['Name'] . '</b>' . chr(9) . $item['Class'] . '<br>'; | + | |
- | foreach ($item->datafields->data as $df ) { | + | |
- | print chr(9) . $df['code'] . ':' . $df['content'] . '<br>'; | + | |
- | } | + | |
- | } | + | |
- | </code> | + | |
==== 2.2. Informacijos siuntimas į Directo (IN) ==== | ==== 2.2. Informacijos siuntimas į Directo (IN) ==== | ||
Linija 78: | Linija 49: | ||
Šiame pavyzdyje nurodyti URL ir XML pvz. yra visiškai išgalvoti ir negali būti naudojami testavimui. Testavimas visada atliekamas realiame procese. | Šiame pavyzdyje nurodyti URL ir XML pvz. yra visiškai išgalvoti ir negali būti naudojami testavimui. Testavimas visada atliekamas realiame procese. | ||
- | Tarkime, kad šiuo atveju URL pvz. https://directo.gate.ee/xmlcore/this_is_the_worlds_greatest_company/xmlcore.asp | + | Tarkime, kad šiuo atveju URL pvz. https://login.directo.ee/xmlcore/this_is_the_worlds_greatest_company/xmlcore.asp |
Pavyzdinio serviso XSD schemą: [[http://wiki.directo.ee/_media/et/xml_in_arved.xsd|xml_in_arved.xsd]]. | Pavyzdinio serviso XSD schemą: [[http://wiki.directo.ee/_media/et/xml_in_arved.xsd|xml_in_arved.xsd]]. | ||
Linija 95: | Linija 66: | ||
</invoice> | </invoice> | ||
</invoices> | </invoices> | ||
- | </code> | ||
- | |||
- | |||
- | **PHP pavyzdys** | ||
- | <code> | ||
- | $xmldata = '<'.'?xml version="1.0" encoding="UTF-8"?> | ||
- | <invoice AppKey="1234567879012345678790" InvoiceNr="123" | ||
- | InvoiceDate="2015-06-07" CustomerCode="CUST001"> | ||
- | <lines> | ||
- | <line ProductID="KILLERPRODUCT" Quantity="3" UnitPriceWoVAT="123.45"/> | ||
- | <line ProductID="FREESAMPLE" Quantity="1" UnitPriceWoVAT="0.00"/> | ||
- | </lines> | ||
- | </invoice>'; | ||
- | |||
- | $url = 'https://directo.gate.ee/xmlcore/this_is_the_worlds_greatest_company/xmlcore.asp'; | ||
- | |||
- | $ch = curl_init(); | ||
- | curl_setopt($ch, CURLOPT_HEADER, 0); | ||
- | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | ||
- | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); | ||
- | curl_setopt($ch, CURLOPT_URL, $url ); | ||
- | curl_setopt($ch, CURLOPT_POST, 1); | ||
- | |||
- | curl_setopt($ch, CURLOPT_POSTFIELDS, 'xmldata='.urlencode($xmldata).'&put=1&what=invoice' ); | ||
- | $result = curl_exec($ch); | ||
- | |||
- | print '<textarea cols=80 rows=10>' . $result . '</textarea>'; | ||
- | |||
- | curl_close($ch); | ||
- | |||
</code> | </code> | ||
Linija 173: | Linija 114: | ||
<code> | <code> | ||
- | <form method="POST" action="https://directo.gate.ee/xmlcore/demo_lt_153/xmlcore.asp"> | + | <form method="POST" action="https://login.directo.ee/xmlcore/demo_lt_153/xmlcore.asp"> |
<input name="what" value="order"> | <input name="what" value="order"> | ||
Linija 184: | Linija 125: | ||
</form> | </form> | ||
+ | </code> | ||
+ | |||
+ | |||
+ | ==== 2.4. Pavyzdys PHP kalba ==== | ||
+ | |||
+ | **OUT** | ||
+ | <code> | ||
+ | $url = 'https://login.directo.ee/xmlcore/demo_ee/xmlcore.asp?get=1&what=item&key=20DAF3F822B782AF12D1198C23F45604'; | ||
+ | |||
+ | $ch = curl_init(); | ||
+ | curl_setopt($ch, CURLOPT_HEADER, 0); | ||
+ | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | ||
+ | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); | ||
+ | curl_setopt($ch, CURLOPT_URL, $url ); | ||
+ | curl_setopt($ch, CURLOPT_POST, 0); | ||
+ | |||
+ | $result = curl_exec($ch); | ||
+ | |||
+ | header('Content-Type: text/html; charset=utf-8'); | ||
+ | |||
+ | print '<textarea cols=80 rows=10>' . $result . '</textarea>'; | ||
+ | |||
+ | $data = new SimpleXMLElement($result); | ||
+ | |||
+ | print '<pre>'; | ||
+ | |||
+ | foreach ($data->items->item as $item) { | ||
+ | print $item['Code'] . chr(9) . '<b>' . $item['Name'] . '</b>' . chr(9) . $item['Class'] . '<br>'; | ||
+ | foreach ($item->datafields->data as $df ) { | ||
+ | print chr(9) . $df['code'] . ':' . $df['content'] . '<br>'; | ||
+ | } | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | |||
+ | **IN** | ||
+ | <code> | ||
+ | $xmldata = '<'.'?xml version="1.0" encoding="UTF-8"?> | ||
+ | <invoice AppKey="1234567879012345678790" InvoiceNr="123" | ||
+ | InvoiceDate="2015-06-07" CustomerCode="CUST001"> | ||
+ | <lines> | ||
+ | <line ProductID="KILLERPRODUCT" Quantity="3" UnitPriceWoVAT="123.45"/> | ||
+ | <line ProductID="FREESAMPLE" Quantity="1" UnitPriceWoVAT="0.00"/> | ||
+ | </lines> | ||
+ | </invoice>'; | ||
+ | |||
+ | $url = 'https://login.directo.ee/xmlcore/this_is_the_worlds_greatest_company/xmlcore.asp'; | ||
+ | |||
+ | $ch = curl_init(); | ||
+ | curl_setopt($ch, CURLOPT_HEADER, 0); | ||
+ | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | ||
+ | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); | ||
+ | curl_setopt($ch, CURLOPT_URL, $url ); | ||
+ | curl_setopt($ch, CURLOPT_POST, 1); | ||
+ | |||
+ | curl_setopt($ch, CURLOPT_POSTFIELDS, 'xmldata='.urlencode($xmldata).'&put=1&what=invoice' ); | ||
+ | $result = curl_exec($ch); | ||
+ | |||
+ | print '<textarea cols=80 rows=10>' . $result . '</textarea>'; | ||
+ | |||
+ | curl_close($ch); | ||
+ | |||
</code> | </code> |