DEFINE VAR vh_WebService AS HANDLE NO-UNDO. DEFINE VAR vh_ReportService AS HANDLE NO-UNDO. DEFINE VAR vc_Binary AS LONGCHAR NO-UNDO. DEFINE VAR vc_remoteReportCallReturn AS LONGCHAR NO-UNDO. DEFINE VAR vc_ReportServiceRequest AS LONGCHAR NO-UNDO. DEFINE VAR vi_CntBegin AS INTEGER NO-UNDO. DEFINE VAR vi_CntEnd AS INTEGER NO-UNDO. DEFINE VAR vm_decd_mptr AS MEMPTR NO-UNDO. CREATE SERVER vh_WebService. vh_WebService:CONNECT("-WSDL 'http://localhost:8080/services/ReportService?wsdl'"). RUN ReportService SET vh_ReportService ON vh_WebService. ASSIGN vc_ReportServiceRequest = " admin@yellowfin.com.au test 1 PDF RRBY ". RUN remoteReportCall IN vh_ReportService(INPUT vc_ReportServiceRequest, OUTPUT vc_remoteReportCallReturn). COPY-LOB FROM vc_remoteReportCallReturn TO FILE "C:\Temp\YFResponse.txt". ASSIGN vi_CntBegin = INDEX(vc_remoteReportCallReturn,"") - vi_CntBegin vc_Binary = SUBSTRING(vc_remoteReportCallReturn,vi_CntBegin,vi_CntEnd) vc_Binary = REPLACE(vc_Binary," ", CHR(10)) . COPY-LOB FROM vc_Binary TO FILE "C:\Temp\YFReportBinary.txt". MESSAGE "Length of document" LENGTH(vc_Binary) VIEW-AS ALERT-BOX INFO BUTTONS OK. ASSIGN vm_decd_mptr = BASE64-DECODE( vc_Binary ) NO-ERROR. IF ERROR-STATUS:ERROR OR vm_decd_mptr = ? THEN DO: SET-SIZE(vm_decd_mptr) = 0. MESSAGE SUBSTITUTE("Can't decode document: &1", ERROR-STATUS:GET-MESSAGE(1)) VIEW-AS ALERT-BOX WARNING BUTTONS OK. RETURN ERROR. /* Generates SOAP fault */ END. /* IF ERROR-STATUS:ERROR OR vm_decd_mptr = ? */ ELSE DO: COPY-LOB FROM vm_decd_mptr TO FILE "C:\Temp\YFReport.pdf". MESSAGE "File conversion successful!" SKIP "Document decoded size:" GET-SIZE(vm_decd_mptr) VIEW-AS ALERT-BOX INFO BUTTONS OK. END.