Baza wiedzy Trawers ERP › e-Trawers EDI SOA e-mail › SOA Integracja danych APISOA Programy w Python i PHP
1. Opis ogólny
2. Program w Python
2.1 Operatorzy Users
2.2 Indeks wg symbolu ProductGetByKey
2.3 Stany indeksu w magazynach StockAtDepot
2.4 Stany indeksu w magazynie 10 StockAtDepot
3. Program w PHP
3.1 Program trsoa1.php (About)
3.2 Program trsoa2.php (Użycie formularzy HTML)
4. Tematy powiązane
1. Opis ogólny
Przykłady prostych aplikacji (programów) internetowych wykorzystujących
mechanizmy SOA programu Trawers
NOTE: Opublikowany plik WSDL ma charakter informacyjny. Nie może służyć
do automatyzacji wykorzystania usług SOA programu Trawers.
Funkcje (usługi) SOA należy wykonywać przy użyciu plików wymiany XML
2. Program w Python
Programy w języku Python z użyciem biblioteki: suds
http://www.python.org/
https://fedorahosted.org/suds/
2.1 Operatorzy Users
Odpowiedź: Lista operatorów
from suds.client import Client
client = Client('http://127.0.0.1:7000/Trawers?wsdl')
print(client.service.users())
Odpowiedź:
---------
(usersResult){
user[] =
(userType){
key = "AA"
surname = "Administrator"
forename = "Adam Abacki "
},
(userType){
key = "DD"
surname = "Magazynier"
forename = "Damian Dworak "
},
(userType){
key = "GN"
surname = "England"
forename = "Graham Norton in"
},
(userType){
key = "KK"
surname = "Księgowa"
forename = "Karin Kowalska "
},
(userType){
key = "SP"
surname = "Sprzedawca"
forename = "Stefan Pilecki "
},
}
2.2 Indeks wg symbolu ProductGetByKey
Odpowiedź: Informacje o indeksie z KIM
from suds.client import Client
client = Client('http://127.0.0.1:7000/Trawers?wsdl')
print(client.service.productGetByKey('Indeks-2'))
Odpowiedź:
---------
(reply){
key = "INDEKS-2"
vat = 23.0
code = "2222222222222"
info = "To jest dodatkowy opis (remark) produktu 2"
name = "Indeks-2 Produkt"
pkwiu = "25.94.1"
packed = 1.0
lastIssue = 2012-08-31
publisher = ""
defChainKey = "szt"
defGroupKey = "20"
lastReceipt = 2012-11-22
lastPurchase = None
rebateGroupKey = None
lastReceiptPrice = 20.0
lastPurchasePrice = 20.0
}
2.3 Stany indeksu w magazynach StockAtDepot
Odpowiedź: Ilości indeksu w magazynach
from suds.client import Client
client = Client('http://127.0.0.1:7000/Trawers?wsdl')
print(client.service.stockAtDepot('Indeks-2'))
Odpowiedź:
---------
(stockAtDepotResult){
stock[] =
(stockAtDepotValueType){
depot = "10"
value = "3.000"
lastIssue = 2012-08-31
lastReceipt = 2012-11-22
lastPurchase = None
},
(stockAtDepotValueType){
depot = "40"
value = "0.000"
lastIssue = None
lastReceipt = None
lastPurchase = None
},
chainKey = "szt"
productKey = "INDEKS-2"
}
2.4 Stany indeksu w magazynie 10 StockAtDepot
Odpowiedź: Ilość indeksu w magazynie 10
from suds.client import Client
client = Client('http://127.0.0.1:7000/Trawers?wsdl')
print(client.service.stockAtDepot(productKey='Indeks-2', depot='10'))
Odpowiedź:
---------
(stockAtDepotResult){
stock[] =
(stockAtDepotValueType){
depot = "10"
value = "3.000"
lastIssue = 2012-08-31
lastReceipt = 2012-11-22
lastPurchase = None
},
chainKey = "szt"
productKey = "INDEKS-2"
}
3. Programy w PHP
Przykładowe programy w języku PHP pokazujące wywołanie funkcji SOA Trawers
Znajdują się na https://ftp.tres.pl/integracja/soa/php
Programy wykorzystują pakiet php-soap. Wymagają serwera internetowego, np. apache
3.1 Program trsoa1.php
Funkcja podaje informacje o programie: About
// poczatek trsoa1.php
echo "<html><body><pre>";
$location = "http://127.0.0.1:7000";
$client = new SoapClient(null, array("trace" => 1,
"uri"=>"",
"location"=> $location));
// funkcja bez parametrow
$func = "About";
$res = $client->__soapCall($func, array());
echo "<br/><b>Wynik funkcji: $func </b><br/>";
print_r($res);
// funkcja z parametrami
$func = "CustomerGetByKey";
$params = array(new SoapParam("000001", "customerKey"));
$res = $client->__soapCall($func, $params);
echo "<br/><b>Wynik funkcji: $func </b><br/>";
print_r($res);
echo "</pre></body></html>";
// koniec trsoa1.php
-------------------------------------
Wynik funkcji: About
Array
(
[mcks] => 01
[odmiana] => TR-DBF-X 64 bit
[nrWersji] => 5
[nrSeryjny] => 99912019
[wersjaGtk] => 2.10.13
[kompilator] => Harbour Linux
[nrLicencji] => DEMO00
[wolneMiejsce] => 782MB
[wydanieZDnia] => 2014.02.27
[wydluzonyRok] =>
[zaakceptowal] => AA 2014.01.16
[maxIloscSesji] => 3
[dataKompilacji] => 20140304, 11:49:56
[nazwaUzytkownika] => Wersja Demonstracyjna
[wydrukiGraficzne] => Tak (GTK 2.10.13)
[dataUplywuAbonamentu] => ...
[dataUdzieleniaLicencji] => 2013.12.06
)
Wynik funkcji: CustomerGetByKey
Array
(
[fax] =>
[key] => 000001
[nip] => 111-111-11-11
[tel] =>
[vat] => true
[zip] => 81-370
[city] => Gdynia
[code] => 000001
[mail] =>
[name] => Odbiorca 1
[note] =>
[type] => RECIPIENT
[person] =>
[street] => Kwiatowa
[enabled] => true
[payment] => CASH
[discount] => 0.00
[maturity] => 0
[priceList] => 1
[creditLimit] => 5000.00
[ordersBlocked] => false
)
3.2 Program trsoa2.php
Program pokazuje wywołanie funkcji Trawers SOA z wykorzystaniem formularzy HTML
Zawiera warstwę komunikacji (PHP) i warstwę prezentacji (HTML, CSS, JavaScript)
https://ftp.tres.pl/integracja/soa/php/trsoa1.php
4. Tematy powiązane
SOA Architektura wymiany danych
SOA Funkcje
SOA Przykłady i ćwiczenia
Słowa kluczowe
#Admin-WymianaDanych
#TrawersERP-Komponenty
#TrawersERP-Środowisko
#TrawersERP-Chmura
#TrawersERP-SOA/API