Hi,
I have created a webservice from PB 12.5 Classic.
Webservice got a function that receive some parameters, retrieve data from DB in a datastore and then save ds as a pdf file (in C:\temp\PDFs\) and then return name and path of file created.
From Asp.Net MVC i call webservice and then i receive path and name of new file.
Problem is that everything works fine but save ds as pdf file.
I got installed GS and a printer for creating PDF
Any idea about this error and solution?
This is the code in NVO (always return ERROR_-2):
dataStore ldst_report
string ls_dataobject, ls_filename, ls_path, ls_filenameguid
long ll_rows, ll_returnthis.of_populatedbparm (as_server, as_database, as_user, as_password)
if not SQLCA.of_isconnected( ) Then
IF SQLCA.of_connect( ) = -1 Then
as_filename = "ERROR_-1 "
Return
end if
end ifls_filenameguid = as_filename
as_filename = "ERROR_0"
ls_dataobject = as_report + "_" + as_language
ldst_report = CREATE dataStore
ldst_report.dataObject = ls_dataobject
ldst_report.SetTransObject(SQLCA)
ll_rows = ldst_report.Retrieve(al_centroid, as_sqlwhere, as_userid, as_rolename, as_applicationname, as_sqldateformat)
al_rows = ll_rowsif ll_rows > 0 Then
ls_path = "C:\temp\PDFs\"
ls_filename = ls_filenameguid + ".pdf"
ls_path = ls_path + ls_filename
ldst_report.Object.DataWindow.Export.PDF.Method = Distill!
ldst_report.Object.DataWindow.Printer = "Sybase DataWindow PS"
ldst_report.Object.DataWindow.Export.PDF.Distill.CustomPostScript="No"
ll_return = ldst_report.SaveAs(ls_path, PDF!, TRUE)
as_filename = ls_filename
if (ll_return <> 1) Then as_filename = "ERROR_-2 " + ls_path
End IfDESTROY ldst_report
SQLCA.of_disconnect( )
If you change the location of where the Web Service source code is ... you need to update the Controller and Interface classes in the "PDF_WebService.pbl;" library with the location that you are using in the PB IDE.
Also, make sure that you set debugging on in the WebService.INI file and then look for the WS's log file in the WS work area for more information.
HTH
Regards ... Chris
it's working right but PDF generation fails:
2018/06/26 17:07:52 - Start of PDF generation!
2018/06/26 17:07:52 - Run API => C:\Dev\PB12\STD_FC_PDF\Deploy\PDFCreate.exe C:\Dev\PB12\STD_FC_PDF\Deploy\CustomerList.pdf
2018/06/26 17:07:52 - PDF generation - RC: -1
¿exe got to be in the same directory than webservice?
First of all, make sure that the PDFCreate App works from the IDE. If necessary, recompile the EXE to make sure that it matches your build of Appeon PB. Then you can deploy it to a folder under IIS. Make sure that the folder you create under IIS (ie: c:\inetpub\wwwroot\pdf) has "everyone" (or at least IIS_IUSRS) privileges and that the new folder is not write protected.
Now make sure that you change the WebService.INI PDF section to match where you deployed the CreatePDF.exe, as follows:
[PDF]
EXE_Path=C:\inetpub\wwwroot\Reports\
EXE_Name=PDFCreate.exe
PDF_Path=C:\inetpub\wwwroot\Reports\
PDF_Name=CustomerList.pdf
Also when running the CreatePDF app, its built from the Integrated framework and will create a log in the same folder as the EXE. Make sure that you check this log as well for issues when this App is called from the WebService.
PS: Run the CreatePDF.exe from its installed folder and see if it works OK. There might be a GhostScript issue that needs attention first. Like properly installing the printer "Sybase DataWindow PS" printer from the GhostScript LIB folder, forgetting to add GS_DLL to the environment variables of the IIS server, etc.
HTH
Regards ... Chris