"Callback functions are not allowed" (pdf-report via WS)

ehs
Member Posts: 34
I am trying to use this very interesting example from the NAV Team blog:
http://blogs.msdn.com/b/nav/archive/200 ... rvice.aspx
The only difference in my configuration is that I have installed the SQL + NAV server on a server and I run the Visual Web example on a client PC (in the example everything runs on the same local PC) . Therefore my code looks like this:
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim service As localhost.Get_PDF_Report = New localhost.Get_PDF_Report()
service.UseDefaultCredentials = True
service.Url = "http://myservername:7047/DynamicsNAV/WS/MyCompanyName/Codeunit/Get_PDF_Report"
Response.ContentType = "application/pdf"
Dim pdfFileName As String = service.GenerateReport()
Response.TransmitFile(pdfFileName)
End Sub
End Class
When I activate the button the pdf document is created just fine in the directory on the server but the code stops when it is going to transfer the document to my client with the debugger in Visual Web Developer saying "Callback functions are not allowed".
The function which is being called in codeunit 419 loos like this:
DownloadTempFile(ServerFileName : Text[1024]) : Text[1024]
IF NOT ISSERVICETIER THEN
EXIT(ServerFileName);
FileName := ServerFileName;
Path := Magicpath;
DOWNLOAD(ServerFileName,'',Path,Text009,FileName);
EXIT(FileName);
I guess that the error is related to a requested user interaction?
Any suggestions to what I should change?
All NAV components are NAV2009R2.
http://blogs.msdn.com/b/nav/archive/200 ... rvice.aspx
The only difference in my configuration is that I have installed the SQL + NAV server on a server and I run the Visual Web example on a client PC (in the example everything runs on the same local PC) . Therefore my code looks like this:
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim service As localhost.Get_PDF_Report = New localhost.Get_PDF_Report()
service.UseDefaultCredentials = True
service.Url = "http://myservername:7047/DynamicsNAV/WS/MyCompanyName/Codeunit/Get_PDF_Report"
Response.ContentType = "application/pdf"
Dim pdfFileName As String = service.GenerateReport()
Response.TransmitFile(pdfFileName)
End Sub
End Class
When I activate the button the pdf document is created just fine in the directory on the server but the code stops when it is going to transfer the document to my client with the debugger in Visual Web Developer saying "Callback functions are not allowed".
The function which is being called in codeunit 419 loos like this:
DownloadTempFile(ServerFileName : Text[1024]) : Text[1024]
IF NOT ISSERVICETIER THEN
EXIT(ServerFileName);
FileName := ServerFileName;
Path := Magicpath;
DOWNLOAD(ServerFileName,'',Path,Text009,FileName);
EXIT(FileName);
I guess that the error is related to a requested user interaction?
Any suggestions to what I should change?
All NAV components are NAV2009R2.
0
Answers
-
Is some dialog displayed in the report you are running?0
-
In the original report (Report 111) yes, but I have removed the Window.open/update/close commands, and the report is being perfectly saved as a pdf to the destination directory C:\inetpub\pdfdocuments on the server when I activate the button on the webpage.
What I forgot to say was that compared with the original example I have also changed the the following code in the webservice codeunit:
filename := 'C:\inetpub\PdfDocuments\';
filename += FORMAT(CREATEGUID);
filename := DELCHR(filename, '=', '{-}');
filename += '.pdf';
REPORT.SAVEASPDF(111,filename);
EXIT(filename);
to:
filename := 'C:\inetpub\PdfDocuments\';
filename += FORMAT(CREATEGUID);
filename := DELCHR(filename, '=', '{-}');
filename += '.pdf';
REPORT.SAVEASPDF(111,filename);
IF ISSERVICETIER THEN BEGIN
cu419.DownloadTempFile(fileName);
END ELSE
EXIT(fileName);
If I use the original code then the website code which calls the WS can only run locally on the server because the "filename" refers to the directory on the server, but isn't there a way I can transfer the pdf to a an IE client outside the LAN using the webpage in this example?
If the program can only run on the server then I don't see the point of it - there are much easier ways to generate a pdf file and open it locally.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions