Sample code for 30+ languages & platforms
DataFlex

SOAP Request to fseservicetest.sanita.finanze.it with Basic Authentication

See more HTTP Misc Examples

Demonstrates sending a SOAP request to fseservicetest.sanita.finanze.it with Basic Authentication.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoHttp
    Handle hoXml
    String sSoapEnvelope
    String sDomain
    String sPath
    Variant vReq
    Handle hoReq
    Variant vResp
    Handle hoResp
    Handle hoXmlResp
    String sTemp1

    Move False To iSuccess

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

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End
    Get Create (RefClass(cComChilkatXml)) To hoXml
    If (Not(IsComObjectCreated(hoXml))) Begin
        Send CreateComObject of hoXml
    End

    Move False To iSuccess

    // Create the SOAP envelope...
    Set ComTag Of hoXml To "soapenv:Envelope"
    Get ComAddAttribute Of hoXml "xmlns:soapenv" "http://schemas.xmlsoap.org/soap/envelope/" To iSuccess
    Get ComAddAttribute Of hoXml "xmlns:stat" "http://statoconsensirichiesta.xsd.fse.ini.finanze.it" To iSuccess
    Get ComAddAttribute Of hoXml "xmlns:tip" "http://tipodatistatoconsensi.xsd.fse.ini.finanze.it" To iSuccess
    Send ComUpdateChildContent To hoXml "soapenv:Header" ""
    Send ComUpdateChildContent To hoXml "soapenv:Body|stat:StatoConsensiRichiesta|stat:IdentificativoUtente" "XXXXXXAAABBBCCC"
    Send ComUpdateChildContent To hoXml "soapenv:Body|stat:StatoConsensiRichiesta|stat:pinCode" "..."
    Send ComUpdateChildContent To hoXml "soapenv:Body|stat:StatoConsensiRichiesta|stat:IdentificativoOrganizzazione" "999"
    Send ComUpdateChildContent To hoXml "soapenv:Body|stat:StatoConsensiRichiesta|stat:StrutturaUtente" "123456789"
    Send ComUpdateChildContent To hoXml "soapenv:Body|stat:StatoConsensiRichiesta|stat:RuoloUtente" "ZZZ"
    Send ComUpdateChildContent To hoXml "soapenv:Body|stat:StatoConsensiRichiesta|stat:ContestoOperativo" ""
    Send ComUpdateChildContent To hoXml "soapenv:Body|stat:StatoConsensiRichiesta|stat:IdentificativoAssistitoGenitoreTutore" ""
    Send ComUpdateChildContent To hoXml "soapenv:Body|stat:StatoConsensiRichiesta|stat:PresaInCarico" "true"
    Send ComUpdateChildContent To hoXml "soapenv:Body|stat:StatoConsensiRichiesta|stat:TipoAttivita" "READ"
    Send ComUpdateChildContent To hoXml "soapenv:Body|stat:StatoConsensiRichiesta|stat:IdentificativoAssistitoConsenso" "ABCDEFGHIJKLM"
    Get ComGetXml Of hoXml To sSoapEnvelope

    Move "fseservicetest.sanita.finanze.it" To sDomain
    Move "/FseInsServicesWeb/services/fseStatoConsensi" To sPath

    Get Create (RefClass(cComChilkatHttpRequest)) To hoReq
    If (Not(IsComObjectCreated(hoReq))) Begin
        Send CreateComObject of hoReq
    End
    Set ComHttpVerb Of hoReq To "POST"
    Set ComSendCharset Of hoReq To False
    Send ComAddHeader To hoReq "Content-Type" "application/soap+xml; charset=utf-8"
    Set ComPath Of hoReq To sPath
    Get ComLoadBodyFromString Of hoReq sSoapEnvelope "utf-8" To iSuccess

    // User name and Password for Basic Authentication 
    Set ComLogin Of hoHttp To "XXXXXXAAABBBCCC"
    Set ComPassword Of hoHttp To "MYPASSWORD"

    Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
    If (Not(IsComObjectCreated(hoResp))) Begin
        Send CreateComObject of hoResp
    End
    Get pvComObject of hoReq to vReq
    Get pvComObject of hoResp to vResp
    Get ComHttpSReq Of hoHttp sDomain 443 True vReq vResp To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatXml)) To hoXmlResp
    If (Not(IsComObjectCreated(hoXmlResp))) Begin
        Send CreateComObject of hoXmlResp
    End
    Get ComBodyStr Of hoResp To sTemp1
    Get ComLoadXml Of hoXmlResp sTemp1 To iSuccess
    Get ComGetXml Of hoXmlResp To sTemp1
    Showln sTemp1


End_Procedure