WST authentication in a request header
lazarus / 38-Networking and Web Programming
----------------------------------------------------------------------
artix · 2014-11-06 19:57
I'm trying to get a response from a webapi server https://tt.poczta-
polska.pl/Sledzenie/services/Sledzenie?wsdl
I am using Web Service Tools (WST) and I was following http://forum.la
zarus.freepascal.org/index.php/topic,20064.msg116160.html#msg116160
but there is a problem. To send a correct request I need to put in a
header authentication parameters like username and password.
According to the documentation in my requests there should be such a
header:
Code: [Select]
sledzeniepp
PPSA
But how can I add/change a header in a request?
My program: (sending name 'Artur' and in a response should be "Witaj
Artur")
Code: [Select]procedure TForm1.FormCreate(Sender: TObject);
begin
SYNAPSE_RegisterHTTP_Transport();
end;
procedure TForm1.Button1Click(Sender: TObject);
var Client : SledzeniePortType ; // connection
witajparam: witaj_type;
myResult: witajResponse;
begin
Client := wst_CreateInstance_SledzeniePortType() ;
witajparam := witaj_type.Create() ;
witajparam.imie:='Artur';
myresult:=Client.witaj(witajparam);
memo1.Lines.Add(myresult.return);
end;
----------------------------------------------------------------------
mig-31 · 2022-01-25 10:01
For Basic HTTP Authentification in the file synapse_http_protocol.pas
change the constuctor THTTPTransport.Create
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i constructor
THTTPTransport.Create();begin inherited Create(); FConnection :=
THTTPSend.Create(); FConnection.Protocol := '1.1';
FConnection.UserName := ; FConnection.Password :=
;end;
----------------------------------------------------------------------
Thaddy · 2022-01-25 12:57
1.1? Really? Should be - at least - 1.3. Current protocols allow to
fall back to 1.1, but select preferred first.
----------------------------------------------------------------------
mig-31 · 2022-01-25 17:05
First three lines between begin...end are from original code, which I
installed to Lazarus through OPM. I added two last lines
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i
FConnection.UserName := ; FConnection.Password :=
;
In the documentation author mention, that connection through proxy
server is supported by the adding additional parameters to Address
string:
https://wiki.freepascal.org/Web_Service_Toolkit#HTTP_Proxy_Parameters.
I try to find out the place in the code, where this string is parsed
to set ProxyServer, ProxyPort, ProxyUsername, ProxyPassword parameters
for the connection and add my keys UserName and Password to set Basic
HTTP Authentification parameters for the connection, but I'm failed
and I added two lines to the constructor THTTPTransport.Create().