[ dbabic @ 06.04.2007. 09:51 ] @
Jel' može neko napiše demo programčić za skidanje kursne liste sa NBS.
Početnik sam u web servisima pa bi mi to bila velika pomoć.

Unapred hvala
[ Goran Nikolovski @ 06.04.2007. 19:48 ] @
Pazi ja sam za svoj konvertor valuta to napisao, ali bez ikakvih web servisa. To nije tako lako napisati, zato ako ti treba potrudi se, pa napisi sam ...
[ Srki_82 @ 06.04.2007. 19:56 ] @
Koliko znam, negde na NBS sajtu imas stranicu koja ti generise CVS, ASCII, i ko zna u kom jos formatu kursnu listu. Samo je pronadji, skini fajl uz pomoc INET API, Indy, JVCL ili neceg treceg, i parsiraj taj fajl. Trebalo bi da bude prilicno lako.
[ Goran Nikolovski @ 06.04.2007. 23:13 ] @
Imas na stranici http://www.nbs.yu/internet/cirilica/scripts/ondate.html da zatrazis da ti generise kursne liste od 2002 godine. Ja bih ti poslao moj program (deo programa) ali su oni nesto na sajtu menjali pa sada to ne radi, a ja bas i nemam vremena da to popravljam.

Kada sam pravio taj program meni je trebalo nekoliko sati da ga nateram da radi kako treba ali je na kraju radilo. Inace ja sam preuzimao sa sajta kursnu listu u ASCII formatu.
[ dbabic @ 07.04.2007. 10:41 ] @
Za preuzimanje ASCII fajla sa NBS znam. To radi i nije problem. Mene zanima kako to uraditi upotrebom SOAP-a i WSDL fajla na osnovu kojeg u delfiju možeš napraviti unit sa opisom metoda kojim možeš pristupiti web servisu.
Mene zanimaju baš web servisi, a ovaj WSDL fajl koji su oni dali, ima čini mi se samo metode za autentifikaciju i jednu za preuzimanje trenutno aktuelne kursne liste. Ne bi trebalo da bude nikakav problem nekom ko je radio sa SOAP-om.

WSDL izgleda ovako:
-----------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://www.nbs.rs/TempExchangeRatesService" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://www.nbs.rs/TempExchangeRatesService" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://www.nbs.rs/TempExchangeRatesService">
<s:element name="GetCurrentExchangeRates">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="nExchangeRatesListTypeID" type="s:decimal" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetCurrentExchangeRatesResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="GetCurrentExchangeRatesResult">
<s:complexType>
<s:sequence>
<s:element ref="s:schema" />
<s:any />
</s:sequence>
</s:complexType>
</s:element>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="AuthenticationHeader" type="tns:AuthenticationHeader" />
<s:complexType name="AuthenticationHeader">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="UserName" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Password" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="LicenceID" type="s:long" />
</s:sequence>
<s:anyAttribute />
</s:complexType>
<s:element name="GetCurrentExchangeRatesXML">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="nExchangeRatesListTypeID" type="s:decimal" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetCurrentExchangeRatesXMLResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="GetCurrentExchangeRatesXMLResult" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
<wsdl:message name="GetCurrentExchangeRatesSoapIn">
<wsdl:part name="parameters" element="tns:GetCurrentExchangeRates" />
</wsdl:message>
<wsdl:message name="GetCurrentExchangeRatesSoapOut">
<wsdl:part name="parameters" element="tns:GetCurrentExchangeRatesResponse" />
</wsdl:message>
<wsdl:message name="GetCurrentExchangeRatesAuthenticationHeader">
<wsdl:part name="AuthenticationHeader" element="tns:AuthenticationHeader" />
</wsdl:message>
<wsdl:message name="GetCurrentExchangeRatesXMLSoapIn">
<wsdl:part name="parameters" element="tns:GetCurrentExchangeRatesXML" />
</wsdl:message>
<wsdl:message name="GetCurrentExchangeRatesXMLSoapOut">
<wsdl:part name="parameters" element="tns:GetCurrentExchangeRatesXMLResponse" />
</wsdl:message>
<wsdl:message name="GetCurrentExchangeRatesXMLAuthenticationHeader">
<wsdl:part name="AuthenticationHeader" element="tns:AuthenticationHeader" />
</wsdl:message>
<wsdl:portType name="TempExchangeRatesServiceSoap">
<wsdl:operation name="GetCurrentExchangeRates">
<wsdl:input message="tns:GetCurrentExchangeRatesSoapIn" />
<wsdl:output message="tns:GetCurrentExchangeRatesSoapOut" />
</wsdl:operation>
<wsdl:operation name="GetCurrentExchangeRatesXML">
<wsdl:input message="tns:GetCurrentExchangeRatesXMLSoapIn" />
<wsdl:output message="tns:GetCurrentExchangeRatesXMLSoapOut" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="TempExchangeRatesServiceSoap" type="tns:TempExchangeRatesServiceSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="GetCurrentExchangeRates">
<soap:operation soapAction="http://www.nbs.rs/TempExchange...ervice/GetCurrentExchangeRates" style="document" />
<wsdl:input>
<soap:body use="literal" />
<soap:header message="tns:GetCurrentExchangeRatesAuthenticationHeader" part="AuthenticationHeader" use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetCurrentExchangeRatesXML">
<soap:operation soapAction="http://www.nbs.rs/TempExchange...ice/GetCurrentExchangeRatesXML" style="document" />
<wsdl:input>
<soap:body use="literal" />
<soap:header message="tns:GetCurrentExchangeRatesXMLAuthenticationHeader" part="AuthenticationHeader" use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="TempExchangeRatesServiceSoap12" type="tns:TempExchangeRatesServiceSoap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="GetCurrentExchangeRates">
<soap12:operation soapAction="http://www.nbs.rs/TempExchange...ervice/GetCurrentExchangeRates" style="document" />
<wsdl:input>
<soap12:body use="literal" />
<soap12:header message="tns:GetCurrentExchangeRatesAuthenticationHeader" part="AuthenticationHeader" use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetCurrentExchangeRatesXML">
<soap12:operation soapAction="http://www.nbs.rs/TempExchange...ice/GetCurrentExchangeRatesXML" style="document" />
<wsdl:input>
<soap12:body use="literal" />
<soap12:header message="tns:GetCurrentExchangeRatesXMLAuthenticationHeader" part="AuthenticationHeader" use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="TempExchangeRatesService">
<wsdl:port name="TempExchangeRatesServiceSoap" binding="tns:TempExchangeRatesServiceSoap">
<soap:address location="http://webservices.nbs.yu/Comm.../TempExchangeRatesService.asmx" />
</wsdl:port>
<wsdl:port name="TempExchangeRatesServiceSoap12" binding="tns:TempExchangeRatesServiceSoap12">
<soap12:address location="http://webservices.nbs.yu/Comm.../TempExchangeRatesService.asmx" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
-----------------------------------------------------------------
Pozdrav
[ viking13 @ 07.04.2007. 20:35 ] @
0. http://www.nbs.yu/export/inter...006_koriscenje_web_servisa.pdf
1. File -> New -> VCL Forms Application - Delphi for Win32
2. File -> New -> Other -> WebServices -> WSDL Importer
3. http://webservices.nbs.yu/Comm...ExchangeRatesService.asmx?WSDL
4. Finish
5. Finish
6. uses TempExchangeRatesService;
7. GetTempExchangeRatesServiceSoap.GetCurrentExchangeRatesXML(1);
8. Enjoy :)

[ dbabic @ 09.04.2007. 10:26 ] @
"GetTempExchangeRatesServiceSoap.GetCurrentExchangeRatesXML(1)"

--Da samo što kao parametar ne može da se prosledi 1. --

Greška:
Incopatible types 'TXSDecimal' and 'integer'
[ inherited @ 09.04.2007. 12:09 ] @
Citat:
viking13: 0. http://www.nbs.yu/export/inter...006_koriscenje_web_servisa.pdf
1. File -> New -> VCL Forms Application - Delphi for Win32
2. File -> New -> Other -> WebServices -> WSDL Importer
3. http://webservices.nbs.yu/Comm...ExchangeRatesService.asmx?WSDL
4. Finish
5. Finish
6. uses TempExchangeRatesService;
7. GetTempExchangeRatesServiceSoap.GetCurrentExchangeRatesXML(1);
8. Enjoy :)

Dobro, dobili smo jos taj jedan UNIT. Sta se sada desava?
Kako da skidamo tu kursnu listu i ucitamo je u TDBGrid?
[ viking13 @ 09.04.2007. 19:54 ] @
1. Ako traži TXSDecimal, ti mu lepo napravi instancu te klase i podesi joj vrednost.
TXS klase se nalaze u XSBuiltIns unitu.

2. Pošto bi sledeće pitanje sigurno bilo: "A što sad dobijam poruku 'Object reference not set to an instance of an object' i kako da dobijem rezultat?", evo odgovora unapred. U PDF dokumentu piše lepo: "U zaglavlju zahteva (AuthenticationHeader) moraju se proslediti sledeci parametri: UserName, Password, LicenceID". Znači mora da mu se pošalje i header. A samim tim doda i InvokeRegistry unit.

Evo ga jednostavan primer koji dobijeni XML ubaci u Memo (čisto da vidite da cela stvar radi):


Code:

uses
  TempExchangeRatesService, InvokeRegistry, XSBuiltIns;

procedure TForm1.FormCreate(Sender: TObject);
var
   Service: TempExchangeRatesServiceSoap;
   AuthHeader: AuthenticationHeader;
   x: TXSDecimal;
begin
   Service := GetTempExchangeRatesServiceSoap;
   x := TXSDecimal.Create;
   AuthHeader := AuthenticationHeader.Create;
   try
     // eto sad je 1
     x.DecimalString := '1';

     // parametri za pristup iz PDF dokumenta
     AuthHeader.UserName := 'TempTest';
     AuthHeader.Password := 'TempTestPassword';
     AuthHeader.LicenceID := 0;

     // pošalji header (izvrši identifikaciju)
     (Service as ISOAPHeaders).Send(AuthHeader);

     // rezultat metoda GetCurrentExchangeRatesXML stavi u Memo
     Memo1.Lines.Text := Service.GetCurrentExchangeRatesXML(x);
   finally
     AuthHeader.Free;
     x.Free;
     Service := nil;
   end;
end;
[ inherited @ 09.04.2007. 23:07 ] @
Greska:
Citat:
Server was unable to process request. ---> You are not authorized to use this licence!!!
[ dbabic @ 11.04.2007. 08:31 ] @
@viking13
Server was unable to process request. ---> You are not authorized to use this licence!!!

[ Miloš Baić @ 12.04.2007. 16:07 ] @
I, šta se dešava?!!! Ima li odgovora?
[ viking13 @ 13.04.2007. 20:13 ] @
Rezultat primera odozgo izvršen pre nekoliko sekudi:

Citat:

<ExchangeRatesDataSet>
<ExchangeRates>
<ExchangeRateListNumber>70</ExchangeRateListNumber>
<Date>13.04.2007</Date>
<ExchangeRatesListTypeID>1</ExchangeRatesListTypeID>
<CurrencyGroupID>2</CurrencyGroupID>
<CurrencyCode>978</CurrencyCode>
<CurrencyCodeNumChar>978</CurrencyCodeNumChar>
<CurrencyCodeAlfaChar>EUR</CurrencyCodeAlfaChar>
<CountryNameSerLat>Evropska unija</CountryNameSerLat>
<CountryNameEng>European Union</CountryNameEng>
<Unit>1</Unit>
<BuyingRate>80.3631</BuyingRate>
<MiddleRate>80.6049</MiddleRate>
<SellingRate>80.8467</SellingRate>
</ExchangeRates>
...


Apsolutno mi nije jasno kako vam ne radi.

Ajde da probamo još detaljnije

Znači, napraviš novu aplikaciju:
1. File -> New -> VCL Forms Application - Delphi for Win32

Pokreneš WSDL importer:
2. File -> New -> Other -> WebServices -> WSDL Importer

Pastuješ ovo:
3. http://webservices.nbs.yu/Comm...ExchangeRatesService.asmx?WSDL

Klikneš na Finish, pa opet na Finish
4. Finish
5. Finish

Na Form1 dodaš Memo i dva puta klikneš na form.

Prepraviš unit da izgleda ovako:

Code:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

uses
  TempExchangeRatesService, InvokeRegistry, XSBuiltIns;

procedure TForm1.FormCreate(Sender: TObject);
var
   Service: TempExchangeRatesServiceSoap;
   AuthHeader: AuthenticationHeader;
   x: TXSDecimal;
begin
   Service := GetTempExchangeRatesServiceSoap;
   x := TXSDecimal.Create;
   AuthHeader := AuthenticationHeader.Create;
   try
     // eto sad je 1
     x.DecimalString := '1';

     // parametri za pristup iz PDF dokumenta
     AuthHeader.UserName := 'TempTest';
     AuthHeader.Password := 'TempTestPassword';
     AuthHeader.LicenceID := 0;

     // pošalji header (izvrši identifikaciju)
     (Service as ISOAPHeaders).Send(AuthHeader);

     // rezultat metoda GetCurrentExchangeRatesXML stavi u Memo
     Memo1.Lines.Text := Service.GetCurrentExchangeRatesXML(x);
   finally
     AuthHeader.Free;
     x.Free;
     Service := nil;
   end;
end;

end.


Izvršiš aplikaciju i dobiješ rezultat u memou.
[ Miloš Baić @ 14.04.2007. 15:56 ] @
Možda je ovo problem?
Citat:
You are not authorized to view this page
The Web server you are attempting to reach has a list of IP addresses that are not allowed to access the Web site, and the IP address of your browsing computer is on this list.

Please try the following:

* Contact the Web site administrator if you believe you should be able to view this directory or page.

HTTP Error 403.6 - Forbidden: IP address of the client has been rejected.
Internet Information Services (IIS)
[ dudasel @ 16.06.2008. 10:22 ] @
Aleksandre meni nikako da proradi skidanje kursne liste preko NBS pa sam hteo da ti pošaljem kod da ti možda pogledaš u čemu je problem. Ako možeš da mi pomogneš pošalji mi mail na [email protected]
Pozdrav
[ rick_hunter @ 08.09.2008. 00:03 ] @
Na primer kad dobijem rezultat u memo

<ExchangeRatesDataSet>
<ExchangeRates>
<ExchangeRateListNumber>171</ExchangeRateListNumber
<ExchangeRatesDataSet>
<ExchangeRates>
<ExchangeRateListNumber>171</ExchangeRateListNumber>
<Date>05.09.2008</Date>
<ExchangeRatesListTypeID>1</ExchangeRatesListTypeID>
<CurrencyGroupID>2</CurrencyGroupID>
<CurrencyCode>978</CurrencyCode>
<CurrencyCodeNumChar>978</CurrencyCodeNumChar>
<CurrencyCodeAlfaChar>EUR</CurrencyCodeAlfaChar>
<CountryNameSerLat>Evropska unija</CountryNameSerLat>
<CountryNameEng>European Union</CountryNameEng>
<Unit>1</Unit>
<BuyingRate>76.5851</BuyingRate>
<MiddleRate>0.0000</MiddleRate>
<SellingRate>77.0459</SellingRate>
</ExchangeRates>
...

kako da procitam vrednost valute to jest kako da procitam vrednost sa taga <BuyingRate>?

Pokušavao sam da to sve usnimam kao xml pa preko kontrole XMLDocument procitam ali nikako, non stop prijavljuje da je xml sintaksa neispravna.

[ obucina @ 08.09.2008. 15:51 ] @
I meni javlja "Server was unable to process request. ---> You are not authorized to use this licence!!!"
[ viking13 @ 08.09.2008. 20:53 ] @
Dotični servis mi nikada nije trebao i nikada ga nisam koristio za sopstvene potrebe.

Jedini put kada sam ga koristio je bio kad sam vama ovde napisao kako da ga koristite i ja tada nisam imao nikakve probleme sa njim.

Imam sveže reinstaliran laptop bez instaliranog Delphija, pa ne mogu da probam. Probaću za vikend da vidim šta se sada dešava, ali ne očekujem da se nešto značajno promenilo.

Meni se čini da vi sa problemom sa autorizacijom koristite malo stariji delphi, recimo D7. Ili grešim?
[ obucina @ 09.09.2008. 00:14 ] @
Da, sa D7 ima greske, sa D11 nema greske.
[ Hasimbegovic @ 25.12.2010. 16:32 ] @
Bilo bi lepo da neko uploaduje novi kod za kusnu listu nakon izmena koje je uradila NBS ? Stari odavno vise ne radi...