Sample code for 30+ languages & platforms
PowerBuilder

SOAP Request to fseservicetest.sanita.finanze.it with Smart Card Authentication (TS-CNS Italian Card)

See more HTTP Misc Examples

Demonstrates sending a SOAP request to fseservicetest.sanita.finanze.it with Smart Card (TS-CNS Italian Card).

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Http
oleobject loo_Xml
string ls_SoapEnvelope
string ls_Domain
string ls_Path
oleobject loo_Req
oleobject loo_Cert
oleobject loo_Resp
oleobject loo_XmlResp

li_Success = 0

// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if
loo_Xml = create oleobject
li_rc = loo_Xml.ConnectToNewObject("Chilkat.Xml")

li_Success = 0

// --------------------------------------------------------------------------------
// Also see Chilkat's Online WSDL Code Generator
// to generate code and SOAP Request and Response XML for each operation in a WSDL.
// --------------------------------------------------------------------------------

// Create the SOAP envelope...
loo_Xml.Tag = "soapenv:Envelope"
loo_Xml.AddAttribute("xmlns:soapenv","http://schemas.xmlsoap.org/soap/envelope/")
loo_Xml.AddAttribute("xmlns:stat","http://statoconsensirichiesta.xsd.fse.ini.finanze.it")
loo_Xml.AddAttribute("xmlns:tip","http://tipodatistatoconsensi.xsd.fse.ini.finanze.it")
loo_Xml.UpdateChildContent("soapenv:Header","")
loo_Xml.UpdateChildContent("soapenv:Body|stat:StatoConsensiRichiesta|stat:IdentificativoUtente","XXXXXXAAABBBCCC")
loo_Xml.UpdateChildContent("soapenv:Body|stat:StatoConsensiRichiesta|stat:pinCode","...")
loo_Xml.UpdateChildContent("soapenv:Body|stat:StatoConsensiRichiesta|stat:IdentificativoOrganizzazione","999")
loo_Xml.UpdateChildContent("soapenv:Body|stat:StatoConsensiRichiesta|stat:StrutturaUtente","123456789")
loo_Xml.UpdateChildContent("soapenv:Body|stat:StatoConsensiRichiesta|stat:RuoloUtente","ZZZ")
loo_Xml.UpdateChildContent("soapenv:Body|stat:StatoConsensiRichiesta|stat:ContestoOperativo","")
loo_Xml.UpdateChildContent("soapenv:Body|stat:StatoConsensiRichiesta|stat:IdentificativoAssistitoGenitoreTutore","")
loo_Xml.UpdateChildContent("soapenv:Body|stat:StatoConsensiRichiesta|stat:PresaInCarico","true")
loo_Xml.UpdateChildContent("soapenv:Body|stat:StatoConsensiRichiesta|stat:TipoAttivita","READ")
loo_Xml.UpdateChildContent("soapenv:Body|stat:StatoConsensiRichiesta|stat:IdentificativoAssistitoConsenso","ABCDEFGHIJKLM")
ls_SoapEnvelope = loo_Xml.GetXml()

ls_Domain = "fseservicetest.sanita.finanze.it"
ls_Path = "/FseInsServicesWeb/services/fseStatoConsensi"

loo_Req = create oleobject
li_rc = loo_Req.ConnectToNewObject("Chilkat.HttpRequest")

loo_Req.HttpVerb = "POST"
loo_Req.SendCharset = 0
loo_Req.AddHeader("Content-Type","application/soap+xml; charset=utf-8")
loo_Req.Path = ls_Path
li_Success = loo_Req.LoadBodyFromString(ls_SoapEnvelope,"utf-8")

// Load the default certificate from the smartcard currently in the reader.
// (This assumes only one reader with one smartcard containing one certificate.
// If the situation is more complex, you can do it with Chilkat, but it requires
// using the Chilkat certificate store object to get the desired certificate
// from the desired smart card.)
// 
// Note: This is for Windows-only.
loo_Cert = create oleobject
li_rc = loo_Cert.ConnectToNewObject("Chilkat.Cert")

li_Success = loo_Cert.LoadFromSmartcard("")
if li_Success = 0 then
    Write-Debug loo_Cert.LastErrorText
    destroy loo_Http
    destroy loo_Xml
    destroy loo_Req
    destroy loo_Cert
    return
end if

// Tell the Chilkat HTTP object to use the certificate for client authentication.
li_Success = loo_Http.SetSslClientCert(loo_Cert)
if li_Success = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_Xml
    destroy loo_Req
    destroy loo_Cert
    return
end if

loo_Http.TlsVersion = "TLS 1.1"

loo_Resp = create oleobject
li_rc = loo_Resp.ConnectToNewObject("Chilkat.HttpResponse")

li_Success = loo_Http.HttpSReq(ls_Domain,443,1,loo_Req,loo_Resp)
if li_Success = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_Xml
    destroy loo_Req
    destroy loo_Cert
    destroy loo_Resp
    return
end if

loo_XmlResp = create oleobject
li_rc = loo_XmlResp.ConnectToNewObject("Chilkat.Xml")

li_Success = loo_XmlResp.LoadXml(loo_Resp.BodyStr)
Write-Debug loo_XmlResp.GetXml()


destroy loo_Http
destroy loo_Xml
destroy loo_Req
destroy loo_Cert
destroy loo_Resp
destroy loo_XmlResp