Home > Back-end >  Delphi call Https webservice
Delphi call Https webservice

Time:09-17

Had been using THTTPRIO call c # write HTTP webservice, now want to switch to HTTPS webservice, online check the information with TIdHTTPt and TIdSSLIOHandlerSocket implementation, specific usage is not clear, please masters to help you, thank you!
Procedure TForm1. Button1Click (Sender: TObject);
The begin
HTTPRIO1. WSDLLocation:='http://192.168.1.151/JYYWXTService/Service.asmx? WSDL ';
HTTPRIO1. HTTPWebNode. UseUTF8InHeader:=true;
HTTPRIO1. Service:='JYYWXTService';
HTTPRIO1. Port:='JYYWXTServiceSoap';
SaveServe:=HTTPRIO1 as JYYWXTServiceSoap;
Memo1. Lines. The Add (SaveServe UploadData (' 21010117113000001 ', '18 c55', 'B1, B2, B3,'));//UploadData interface function
The end;

Now switch to the "https://192.168.1.151/JYYWXTService/Service.asmx? WSD "don't know how to call UploadData.

CodePudding user response:

You can find it on the Internet, but this method is more troublesome, get files need to parse

CodePudding user response:

There are two ways:
1, want to try, slowly with THTTPRIO and TIdSSLIOHandlerSocket, still should have a CookieManagement control, or can't remember,
2. Use TIdHttp join TIdSSLIOHandlerSocket, caught and then simulate the out-contracting IdHttp. Post ();

CodePudding user response:

IdSSLIOHandlerSocket. Method:=sslvSSLv23; Mode:=ssImBoth;
IdHttp. IOHandler:=IdSSLIOHandlerSocket;
You also need to use libeay32. DLL and ssleay32. Two DLL DLL, can be downloaded from the Internet

CodePudding user response:

Call the HTTPS need libeay32. DLL and ssleay32. DLL.
 
The function TFrmMain. IdHTTPCallWebservice (RequestSOAPHeader: string; Var Response: string) : Boolean;
Var
Sends: TStringList;
ResponseStream: TStringStream;
Err_code: string;
The begin
ResponseStream:=TStringstream. Create (' ', TEncoding UTF8);
//idhttp1. IOHandler:=TIdSSLIOHandlerSocketOpenSSL. Create (self);
Idhttp1. AllowCookies:=false;
Idhttp1. HandleRedirects:=false;
IdHttp1. Request. ContentType:="text/XML";
//idHttp1. Request. ContentType:='application/x - WWW - form - urlencoded';
IdHttp1. Request. Charset:="utf-8";
IdHttp1. HTTPOptions:=[];//close the automatic coding

Sends:=TStringList. Create;
Sends. Text:=RequestSOAPHeader;

//Webservice_url:='https://172.16.45.206:8443/oltp/ws/CksServices';
Idhttp1. Post (Webservice_url, sends, ResponseStream);

Mmo1. Lines. The Clear;

Response:=ReplaceXMLSpecialChr (ResponseStream. DataString);
If CheckWebservicefault (Response, err_code) then
The begin
Mmo1. Lines. The Add (Response);
Mmo1. Lines. SaveToFile (extractfilepath (ParamStr (0)) + 'log \' + edtTRANSACTION_ID. Text + FormatDateTime (" yyyyMMddHHmmss ", now) + 'log');
ShowMessage (err_code);
Result:=False;
End
The else
The begin
Mmo1. Lines. The Add (Response);
Mmo1. Lines. SaveToFile (extractfilepath (ParamStr (0)) + 'log \' + edtTRANSACTION_ID. Text + FormatDateTime (" yyyyMMddHHmmss ", now) + 'log');
Result:=True;
The end;
The end;
  • Related