Rashed Amini

The ara3n weblog

Running Job Queue through NAV Web service for Unlimited Companies

28th January 2009

I had posted on mibuso a while back on how to use two NAS instances to run job queue for unlimited amount of companies. Here is the link

http://www.mibuso.com/forum/viewtopic.php?f=7&t=22633. You had to purchase an additional NAS user license in order to use it. Dynamics NAV 2009 comes with web service, and you can publish any Code unit or Page by default. You will need to purchase one user but for webservice, but it much cheaper. In this blog, I will show you how to setup JOB QUEUE to schedule to run jobs across companies. The advantages of using Web Services is that you can run multiple jobs at the same time for multiple companies. What I’ve experienced with NAV 2009 Web Service is that once you call a web service function, you can disconnect and Service Tier will finish the job and commit the transaction. When you install NAS the Startup Parameter is “JOBQUEUE” without the double quotes.

In addition you don’t have to modify any processing/posting jobs that have dialog windows displayed. The Service tier simply ignores them. For example you can run adjust cost report without modifying any objects from Job queue. In addition, the solution I’ve created does not modify any existing objects!!!

Here are the steps. Import the fob. NAS-JobQueue-WebService . the zip file has a new Codeunit 5000. Open Job Queue Entry Card and Setup to run this job

In Parameter String field you will need to specify the Company you want to run this separated by comma the object type, and the object ID.

For example

CRONUS,Report,795

Or

CRONUS,Codeunit,50010

 

Next we need to publish the new Codeunit as a webservice. In Object designer find the table Web Service 2000000076 and run it.

Make sure you have the correct Case for Service Name.

Next Make sure NAV Web Service is running.

 

To make sure that web service is published you can open Internet Explorer and type this address.

http://localhost:7047/DynamicsNAV/WS/KRONUS/Codeunit/RunJob. Make sure it’s IE and not Firefox. For Firefox you have to enable Kerberos. You can search the web on how to do that. If your webservice is on a different box than where the NAS is running then you need to change the URL from localhost to the computer name.You will also need to change the new codeunit 50000.

Below is a screenshot of the code unit. The whole Codeunit is less than 60 lines of code and it’s self explanatory.

 

 

 

19 Responses to “Running Job Queue through NAV Web service for Unlimited Companies”

  1. Elwin Says:

    This looks at a great solution.
    I tried to get it working. Unfortunately the only thing I get is the error “Http Error 500: Internal Server Error” in the Job Queue Log Entries.
    The webservice is working.

    Can you give me a clue to solve this problem?

    Thanks in advance.

  2. Elwin Says:

    It is working, it was my own fault.

  3. Elwin Says:

    Using your solution on my laptop or in a virtual machine works perfect.
    To test it for real I used our own server. After setup everything codeunit ‘Run NAS WebService’ is called, but the following error message occured in the ‘Job Queue Log Entries’:
    Http Error 401: Unauthorized

    The webservice is ok when calling it from the internet explorer.

    Can someone help me with this?

    Thanks in advance.

  4. ara3n Says:

    Hello Elwin,

    You can ask your question or start a new thread on mibuso forums.

    Here is a link for this post.

    http://www.mibuso.com/forum/viewtopic.php?f=32&t=31476&start=15

  5. ara3n Says:

    You will need to pass authentication information when calling open

    XmlHttp.open(’POST’,'http://localhost:7047/DynamicsNAV/WS/’+OtherCompany+’/Codeunit/RunJob’,0, domain/windowslogin,PASSWORD);

  6. Elwin Says:

    Thanks for your answer, it’s working.

  7. Kriki’s Dynamics NAV blog » Am I a detective? Says:

    […] and goes on with other jobs (thanks to ara3n for his blog that helped me a lot to set it up: http://mibuso.com/blogs/ara3n/2009/01/28/running-job-queue-through-nav-web-service-for-unlimited-com…). The idea was not really using 1 NAS for multiple companies but more using 1 NAS for multiple jobs […]

  8. M Huda Says:

    Hi,
    I have tried the steps above and I keep getting the error in the nas as ‘Unhandled Error. Please check the xml file’.
    I can connect to the web service using IE. Has anything changed for NAV SP1?

  9. Red Says:

    Hi,

    is this compatible with NAV 2009 R2?

    Our job queue log entries shows “This message is for C/AL programmers:
    The call to member send failed. msxml3.dll returned the following message:
    The connection with the server was terminated abnormally”

    We’ve tried running several different codeunits and get the same error

    Cheers
    Red

  10. NavUser Says:

    Hi Rashed,
    I am trying to follow the setup you have posted in this site but im a little confused on the part of changing the codeunit the screenshot u have provided in the webservice part. what codeunit am i exactly going to modify for that part? please advise. thanks.

  11. ara3n Says:

    The CU I’ve provided the link for above for fob. This is just a new Codeunit. No other objects in NAV needs to be modified.

    http://mibuso.com/blogs/ara3n/files/2009/01/nas-webservice.zip

  12. NavUser Says:

    Hi Rashed,
    Thanks for your reply. I have downloaded the CU - Run NAS Accross Company in mibuso thread and follow the instructions provided.

    the one you have provided in this link which contain CU - Run NAS WebService
    http://mibuso.com/blogs/ara3n/files/2009/01/nas-webservice.zip

    Step:
    “Next we need to publish the new Codeunit as a webservice. In Object designer find the table Web Service 2000000076 and run it.\”

    with this, i am confused what should i published in the web service? is it the CU - Run NAS WebService or CU - Run NAS Accross Company? appreciate your advise. thanks

  13. ara3n Says:

    There should be only one CU Run NAS WebService. You schedule it on JOBQUEUE and you publish it as well. The same codeunit.

    The CU Publishes as web service so that function RunJob is seen. Then through NAS it calls the web service. So in a sense it calls itself through web service.

  14. ara3n Says:

    In String Parameter you specify what other CU or Report and for what Company you would like to run it.

  15. NavUser Says:

    Hi Rashed,

    Thanks for the help. I will give you feedback once tested..

  16. Guna Says:

    Hi Rashed,

    I am getting the message \”Http Error 401: Unauthorized\” in my event viewer, however I have given the Authentication details as mentioned in your response 5.

    XmlHttp.open(\’POST\’,\’http://localhost:7047/DynamicsNAV/WS/\’+OtherCompany+\’/Codeunit/RunJob\’,0,user,pwd);

    My Job Queue log is asking me to check the XML file and my xml file says \”XML document must have top level element\”. Can you throw some light on where I am going wrong ?

    Thanks
    Guna

  17. ara3n Says:

    open the response.xml with notepad and see what’s inside it.

  18. Guna Says:

    Hi Rashed,

    Response.xml says XML document must have top level element

    Regards,
    Guna

  19. Guna Says:

    Hi,

    It works now, Removed the authentication details and it started to work. Strange isn’t it.

    Thank a lot Rashed.

    Regards,
    Guna

Leave a Reply

You must be logged in to post a comment.