Novo

Forum kao aplikacija na telefonu

Dodajte forum na početni ekran i koristite ga kao aplikaciju, sa menijem na dnu ekrana.

  • 19 odgovora
  • 19.112 pregleda

Najnovija ↓

Kursna lista NBS 06.04.2007. u 10:51 · pre 238 meseci #1
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
Re: Kursna lista NBS 06.04.2007. u 20:56 · pre 238 meseci #3
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.
Potpis
Play Store
Re: Kursna lista NBS 07.04.2007. u 00:13 · pre 238 meseci #4
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.
Potpis
Moji programi:
Program za rešavanje jednačina
Program za određivanje sastava
betona

Program za određivanje sastava
maltera
Re: Kursna lista NBS 07.04.2007. u 11:41 · pre 238 meseci #5
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
Re: Kursna lista NBS 07.04.2007. u 21:35 · pre 238 meseci #6
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 :)

Potpis
viking ®
Re: Kursna lista NBS 09.04.2007. u 11:26 · pre 238 meseci #7
"GetTempExchangeRatesServiceSoap.GetCurrentExchangeRatesXML(1)"

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

Greška:
Incopatible types 'TXSDecimal' and 'integer'
Re: Kursna lista NBS 09.04.2007. u 13:09 · pre 238 meseci #8
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?
Re: Kursna lista NBS 09.04.2007. u 20:54 · pre 238 meseci #9
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;
Potpis
viking ®
Re: Kursna lista NBS 10.04.2007. u 00:07 · pre 238 meseci #10
Greska:
Citat:
Server was unable to process request. ---> You are not authorized to use this licence!!!
Re: Kursna lista NBS 11.04.2007. u 09:31 · pre 238 meseci #11
@viking13
Server was unable to process request. ---> You are not authorized to use this licence!!!

Re: Kursna lista NBS 12.04.2007. u 17:07 · pre 238 meseci #12
I, šta se dešava?!!! Ima li odgovora?
Potpis
Someone's sitting in the shade today because someone planted a tree a long time ago.
Re: Kursna lista NBS 13.04.2007. u 21:13 · pre 238 meseci #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.
Potpis
viking ®
Re: Kursna lista NBS 14.04.2007. u 16:56 · pre 238 meseci #14
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)
Potpis
Someone's sitting in the shade today because someone planted a tree a long time ago.
Re: Kursna lista NBS 16.06.2008. u 11:22 · pre 223 meseca #15
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
Re: Kursna lista NBS 08.09.2008. u 01:03 · pre 220 meseci #16
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.

Re: Kursna lista NBS 08.09.2008. u 16:51 · pre 220 meseci #17
I meni javlja "Server was unable to process request. ---> You are not authorized to use this licence!!!"
Re: Kursna lista NBS 08.09.2008. u 21:53 · pre 220 meseci #18
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?
Potpis
viking ®
Re: Kursna lista NBS 25.12.2010. u 17:32 · pre 192 meseca #20
Bilo bi lepo da neko uploaduje novi kod za kusnu listu nakon izmena koje je uradila NBS ? Stari odavno vise ne radi...
Prijavite se da biste odgovorili u ovoj temi.PrijavaRegistracija

Premeštanje teme