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.
Answers
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
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.