Using Navision from .NET

Hello Community Members,

I’ve been trying to figure out whether I can insert the data form web to Navision. So basically, the Navision will do all the process before the data end up in the database. I only need to insert data using web based application.

I use msdn technical article (Talking to Navision), for me to understand the basic principle behind this. I’ve follow the article exactly but I didn’t get any message from Navision. After I click the button in my .NET form, it gives me ‘TIMEOUT EXPIRED’ message.

I hope there are somebody can help me on this. I don’t know whether this problem have something to do with my Application Server, MSMQ or the codeunit in NAV itself.

Thank you.

dear friend

its may help you

accessing data from vb

http://www.erpstudies.com/microsoft-dynamics/51-integration-tools-for-navision/58-accessing-data-from-visual-basic.html

try

all the best

Hi Akhilesh,

Thanks for the suggested link. But I don’t think that is what I’m looking for. C/FRONT can’t access business logic in NAV. I need to access the business logic in NAV to ensure the data are process before it stores in database.

The idea is, I want to use NAV as it is. But I just want to change how the data go into the NAV. Rather than using NAV directly, I want to insert the data using web based application. So whenever I want to enter the data, I just open the browser and do it from there. The data will be process in NAV (using c/al code).

By the way, I appreciate your help. It makes me want to know more about C/FRONT.

Hello what you want to know?

See directly you can access via c/front but not include business login.

and another way is to use page based web service by that way you can use business logic used in navision so no need to write extra code.

Himanshu

Navision Developer.

anshpat2826@gmail.com

ph no - 09979876474

Hi Himanshu,

Using webservice without writing any code? Is it possible? I’m using NAV 5.0 SP1. I am very new to NAV and I’m not even the developer for NAV. :-). I’m sorry if I don’t understand your question.

Basically, I follow the this article.

http://msdn.microsoft.com/en-us/library/ms952182.aspx

The problem is, I didn’t get the message from NAV although I already send in from .net. In event viewer, this is the warning message:

The following information is part of the event: This message is for C/AL programmers:

The call to member Send failed. MSMQMessage returned the following message:

No internal Message Queuing certificate exists for the user.

[:)]

Still I did not tried http://msdn.microsoft.com/en-us/library/ms952182.aspx

But i can explain you in detail about web service like how to expose web service .
When you are using web service you need some decent exception Handling.

But for this you need basic knowledge of PHP, JAVA or asp.net to use web service.
also you can follow some blogs written on web service. It will help you a lot how to consume NAVwebservice.

Hi khairul,

it is hard, without more details, to say what is the problem.

But, just to make sure:

do you make right MSMQ rules for NAS service user?

Hi Himanshu,

Yes I really need help in how to consume NAVwebservice. But I guess I need to complete the tutorial successfully before I move on. So I will know the problem that may be exist in consuming the webservice later. Actually, the tutorial that I’m talking about will lead me to the second tutorial which is on consuming the NAVwebservice.

The only problem now is I can’t get NAV to send the message back to .net. If I can get this right, I will start doing the second tutorial. (Accessing Navision Business Layer Through a Web Service ) http://msdn.microsoft.com/en-us/library/ms952079.aspx

Hi vt011,

Basically I follow the tutorial that I mention in my post before. I already write the c/al code in navision, and also in .net. I try to send the message from my winform via MSMQ and I want NAV to retrieve my message and convert it to uppercase before sending it back to my winform.

Below are my c/al code:

Documentation()

OnRun()

CREATE(MQBus);

CREATE(CC2);

CREATE (XMLDom);

CC2.AddBusAdapter(MQBus,1);

MQBus.OpenReceiveQueue(’.\Private$\ToNavision’,0,0);

MESSAGE(‘on run() initiate’);

CC2::MessageReceived(VAR InMessage : Automation “’’.IDISPATCH”)

// get the message

MESSAGE(‘message received’) ;

InMsg := InMessage;

InS := InMsg.GetStream();

// load the message into an XML document and find a node

MESSAGE (‘message load into xml doc n find the node’);

XMLDom.load (InS);

XMLNode := XMLDom.selectSingleNode (‘string’);

// open the response queue and create a new message

MESSAGE (‘open queue n create new message’) ;

MQBus.OpenWriteQueue(’.\Private$\FromNavision’,0,0);

MQBus.SenderAuthenticationLevel:= 2;

OutMsg := CC2.CreateoutMessage(‘Message queue://.\Private$\FromNavision’);

OutS := OutMsg.GetStream();

// build the contents of your message

MESSAGE (‘change to uppercase’);

XMLNode.text := UPPERCASE (XMLNode.text);

// fill the message and send it

ERROR (‘send the message’);

OutS.WRITE(XMLDom.xml);

OutMsg.Send(0);

If you noticed, I put a message in every process that the message went through before it’s send back to my winform (e.g MESSAGE(‘on run() initiate’);,MESSAGE(‘message received’);, etc).

Ok. Now when I run my winform, the message will be create in my private queue in journal folder. But after awhile, I get “Timeout for the requested operation has expired” exception message.

So when I check my event viewer, in the last event log, it become warning event log.

By the way, what is the msmq rules? How I’m suppose to do it?

Regards

-Khairul-

Hi vt011,

Before you misunderstand my statement:

If you noticed, I put a message in every process that the message went through before it’s send back to my winform (e.g MESSAGE(‘on run() initiate’);,MESSAGE(‘message received’);, etc).

→ I mean I put a message in c/al code for every process to convert the msmq message that was received from my winform. So I will know that msmq message has going through every process in my c/al code. The message in c/al code (e.g MESSAGE(‘on run() initiate’);,MESSAGE(‘message received’);, etc ) will be display in my event viewer log.

p/s: Sorry… my english is not so good. After I read back my post to you, even I get a little bit confused. hehe… [:P]

Hi, khairul

do you have any of these messages (‘message received’, ‘message load into xml doc n find the node’,…) in your event log?

Can you send us part of your c# (vb) code, where you receive message to winform?

Hi,

Yes, I have all messages up until ‘send the message’. Below are my C# code:

namespace testing3

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

mqFromNavision.Formatter = new System.Messaging.XmlMessageFormatter(new Type[] { typeof(String) });

}

private void btnSend_Click(object sender, EventArgs e)

{

mqToNavision.Send(txtSend.Text, “Navision MSMQ-BA”);

mqFromNavision.BeginReceive(new System.TimeSpan(0, 0, 0, 30));

}

private void mqFromNavision_ReceiveCompleted(object sender, System.Messaging.ReceiveCompletedEventArgs e)

{

try

{

System.Messaging.Message m = mqFromNavision.EndReceive(e.AsyncResult);

txtReceive.Text = (string)m.Body;

}

catch (MessageQueueException ex)

{

MessageBox.Show(ex.Message);

}

}

}

}

That’s all I have in my C# side.

Thanks.

Khairul,

why do you have a line:ERROR (‘send the message’); ?

Owh… Actually, I try to test whether if I put ERROR it will catch any error message rather than just give me a warning in event log. By the way, is the message below indicated that I’m having problem with my message queue?

This message is for C/AL programmers:

The call to member Send failed. MSMQMessage returned the following message:

No internal Message Queuing certificate exists for the user.

It is weird because I can send msmq message from my winform but it cannot send it back. So I’m not sure whether my message queue is a real issue or not.

did you get such message?

No internal Message Queuing certificate exists for the user.

I think you need licence for such access.

I do not have much experience on MSMQ but i think it required licence for users i will check the problem and inform you when i am free.

Thank You Himanshu,

I’ve been trying to search for this too. Apparently, it’s because my machine are in workgroup mode rather than in domain mode. So far, I only know that maybe I need to use external certificate not internal.

By the way, I still figure out how to use external certificate rather than internal certificate.

My Friends,

Thank You for your hard works. I really appreciate it. At last, I figure out the problem. The problem was in C/AL code. We didn’t need code (MQBus.SenderAuthenticationLevel:= 2;). This is the cause of internal certificate problem.

But I still don’t know whether it will affect the security later when I’ll try to consume NAVwebservice. By the way, I’m really glad that this community really want to help me out. Thank You very much Akhilesh, Himanshu and vt011. [;)]

Use Navision Web service.

http://dynamicsuser.net/blogs/waldo/archive/2010/05/14/nav-2009-web-services-extending-a-page-web-service.aspx