大家好,很抱歉我的英语很差。
我在查询需要基本身份验证证书的Web服务时遇到问题。这是我创建的代码
procedure Tmenu.btnConverterClick (Sender: TObject);
var
_ccSoap: VisualizzaErogatoRicevuta;
_rio: THTTPRIO;
ParametridaPassare: VisualizzaErogatoRichiesta;
myservice: visualizzaErogatoPT;
begin
_rio: = THTTPRIO.Create (Self);
_rio.OnBeforeExecute: = Self.httpRioBeforeExecute;
_rio.OnAfterExecute: = Self.httpRioAfterExecute;
_rio.HTTPWebNode.OnBeforePost: = Self.HTTPRIOHTTPWebNode1BeforePost;
_rio.URL:='https://demservicetest.sanita.finanze.it/DemRicettaErogatoServicesWeb/services/demVisualizzaErogato';
ParametridaPassare: = VisualizzaErogatoRichiesta.Create;
_ccSoap: = VisualizzaErogatoRicevuta.Create;
ParametridaPassare.pinCode: = 'xxxx';
ParametridaPassare.codiceRegioneErogatore: = '222';
ParametridaPassare.codiceAslErogatore: = '299';
ParametridaPassare.codiceSsaErogatore: = '33333338';
ParametridaPassare.nre: = '190345435345';
ParametridaPassare.tipoOperazione: = '1';
myservice: = _ rio as visualizzaErogatoPT;
_ccSoap: = myservice.visualizzaErogato (ParametridaPassare);
try
ShowMessage (_ccsoap.cognNome);
ShowMessage (_ccsoap.codiceAss);
ShowMessage (_ccsoap.cfMedico1);
ShowMessage (_ccsoap.cfMedico2);
ShowMessage (_ccsoap.descrizioneDiagnosi);
ShowMessage (_ccsoap.nre);
finally
_ccSoap: = nil;
end;
end;
procedure TMenu.HTTPRIOHTTPWebNode1BeforePost (const HTTPReqResp: THTTPReqResp; Data: Pointer);
Const
INTERNET_OPTION_CLIENT_CERT_CONTEXT = 84;
var
Store : IStore;
Certs : ICertificates;
Cert : ICertificate2;
CertContext : ICertContext;
PCertContext : PCCERT_CONTEXT;
V : OleVariant;
SS,S : String;
CertificateFilename: PWideChar;
Certificate: ICertificate2;
Password: String;
i : integer;
UserName: string;
begin
V := '6C791E67ACD205940DB36444BDB5C81FD89A2214';
Store := CoStore.Create;
(* open the My Store containing certs with private keys *)
Store.Open( CAPICOM_CURRENT_USER_STORE, 'MY', CAPICOM_STORE_OPEN_MAXIMUM_ALLOWED );
Certs := Store.Certificates;
for i := 1 to certs.Count do
begin
cert := IInterface(Certs.Item[i]) as ICertificate2;
ss:=cert.SubjectName;
if cert.Thumbprint=V then
begin
CertContext := Cert as ICertContext;
CertContext.Get_CertContext( Integer( PCertContext ) );
HTTPReqResp.ClientCertificate.CertName:=cert.SubjectName;
HTTPReqResp.ClientCertificate.Issuer:=cert.IssuerName;
HTTPReqResp.ClientCertificate.SerialNum:=cert.SerialNumber;
if InternetSetOption( Data, INTERNET_OPTION_CLIENT_CERT_CONTEXT, PCertContext, Sizeof( CERT_CONTEXT ) ) = False then
begin
ShowMessage( 'Problema no certificado!!!!!!!!!!' );
end;
end
end;
procedure TMenu.httpRioAfterExecute(const MethodName: string;
SOAPResponse: TStream);
begin
SOAPResponse.Position := 0;
mmResponse.Lines.LoadFromStream(SOAPResponse);
SOAPResponse.Position := 0;
end;
procedure TMenu.httpRioBeforeExecute(const MethodName: string;
SOAPRequest: TStream);
begin
SOAPRequest.Position := 0;
mmRequest.Lines.LoadFromStream(SOAPRequest);
SOAPRequest.Position := 0;
end;
似乎证书已正确加载。有什么说明,我在哪里可以通过BASE64中的用户名和密码在基本认证中查询Web服务?
谢谢大家的帮助。