1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Stackoverflow]

Discussão em 'StackOverflow' iniciado por fdantas, Setembro 10, 2024.

  1. fdantas

    fdantas Administrator Moderador

    I'm using V-11.7 and I have no problems using HttpClient in differents scenarios, GET, POST, uploading files, getting the responses, etc. But now I have to upload an XML to an public admnistracion URL's that requires a valid certificate.

    I have to use a P12 cert to connect to a webservice and I don't see the way.

    Alternativelly I'm using cURL to accomplish this using this command:

    lcComan = "C:\Teragest\FacE\curl.exe" +
    " -k" +
    " -H " + CHR(34) + "Content-type: application/xml;charset=UTF-8" + CHR(34) +
    " --data-binary @" + lcFiche + ".xml" +
    " -o " + lcFiche + "out.xml" +
    " -v" +
    " --key " + lcpemKey +
    " --cacert " + lcpemCacert +
    " --cert " + lcpemCert + ":" + lcpemPass +
    " " + lcUrl.
    OS-COMMAND VALUE(lcComan).


    I don't have to receive a binary, he response in this case is a simple XML.

    I tried to add header that reference the certificate but didnt work at all:

    oLib = ClientLibraryBuilder:Build():sslVerifyHost(NO):LIBRARY. /*ServerNameIndicator("pruebas- ticketbai.araba.eus"):SetSSLProtocols(cSSLProtocols):SetSSLCiphers(cSSLCiphers):library. */
    oHttpClient = ClientBuilder:Build():UsingLibrary(oLib):Client.
    oRequest = RequestBuilder:post(lcUrl,oDocument):AddHeader("Content-Type","application/xml;charset=UTF-8")
    :AddHeader("key", lcpemKey)
    :AddHeader("cacert", lcpemCacert)
    :AddHeader("--cert-type","P12")
    :AddHeader("--cert", cRuta + cNif + ".p12" + ":" + lcpemPass):Request.
    oResponse = ResponseBuilder:Build():Response.
    oHttpClient:Execute(oRequest, oResponse).`


    There is a method to do this with HttpClient? Thank you all!

    Continue reading...

Compartilhe esta Página