AIF, Report: Save InvoiceReport as PDF into specified folder, gives the error "A call to the Microsoft Dynamics AX SRSFrameworkService service failed. Failed to logon to Microsoft Dynamics AX"

I have written AIF service to save the invoice report to a specified folder. i pass invoice Id to the service which should save the pdf. The same code which i wrote is working from Job. but when i call the service from C# application i am getting “A call to the Microsoft Dynamics AX SRSFrameworkService service failed. Failed to logon to Microsoft Dynamics AX” error.

Any help is appreciated to solve this problem.

Here is my code in the service method:

private void saveInvoice(FilePath _filePath, InvoiceId _invoiceId)

{

srsprintdestinationsettings settings;

SrsReportRunController controller = new ReceiptController();

FreeTextInvoiceContract rdpcontract = new FreeTextInvoiceContract();

select * from custJour where custJour.InvoiceId == _invoiceId;

controller.parmreportname(ssrsreportstr(FreeTextInvoice,Report));

controller.parmLoadFromSysLastValue(false);

controller.parmshowdialog(false);

rdpcontract.parmCustInvoiceJourRecId(custJour.RecId);

controller.parmReportContract().parmRdpContract(rdpcontract);

settings = controller.parmReportContract().parmPrintSettings();

settings.printMediumType(SRSPrintMediumType::File);

settings.fileFormat(SRSReportFileFormat::PDF);

settings.overwriteFile(true);

settings.fileName(_filePath);

controller.startOperation();

}

Does your code works if you run it in CIL?

Running it in a job uses a different language, process and runtime environment, so it’s not really comparable.

Sorry i don’t know how to run in CIL. Can you guide me how to run in CIL. Thanks

But you are aware of that code executed by web services runs in CIL and you have to generate CIL after changing X++, aren’t you?

Instead of calling your code from a job, call it from a class method (instance method without parameters). Then create a menu and set its properties like this:

  • ObjectType: Class
  • Object: SysOperationServiceController
  • EnumTypeParameter: SysOperationExecutionMode
  • EnumParameter: Synchronous
  • Parameters: YourClass.yourMethod

That’s probably the easiest way. Again, don’t forget to generate CIL before running it.

Mr. Martin,

Thanks for the Steps. i did the same what you mentioned. i am able to run the service method to save the pdf without any issue.

Can you give your thoughts what else i should do to resolve my error.

I’ve never printing from a web service, so I don’t know whether it’s supported, what happens with WCF configuration for AX services (namelySRSFrameworkService) and authentication and so on.

You have more steps to try to collect more information: check event logs, use debugger and tracing to collect extra data, try a proof of concept with a simplified case… It’s difficult just to guess what happened.

Thanks for your help Martin. i really appreciate your support.[:)]