I’m starting an extranet project, where php pages are supposed to send data to Microsoft Dynamics NAV.
I haven’t used NAV before, but I found some info here.
The example php code looks pretty clear to me, but is there any tips or tricks (basics) that I should know before starting this project? all examples are welcome…
How to connect with Navision's web services from PHP
Step 1 : Checking your configuration
You need to make sure that NTLM is enabled in the CustomSettings.config file :
Step 2 : Choose between OData and SOAP
Since Microsoft Dynamics NAV 2009, Microsoft Dynamics NAV supports OData web services in addition to the SOAP web services. Personally, I find the Odata protocol a lot more intuitive than the SOAP protocol.
OData also has the additional advantage of supporting Json instead of XML for communicating between server and client, which makes conversion from and to standard PHP arrays or objects easy as pie.
See the official MSDN documentation for more info on where to find a list of existing web services (with corresponding URLs) and how to register new ones.
Step 3 : Sending a HTTP request :
If you're going with SOAP, you might want to use PHP's SoapClient or some third party library based on it for sending and receiving SOAP messages.
However, if you know how to parse XML in PHP, you could just use cURL and parse the XML responses yourself. Or, if you've chosen for the Odata protocol, you could use Json messages instead. SOAP is XML only.
Anyway, if you're using cURL, sending a GET request to your SOAP or Odata service can really be as simple as this :
Step 3 : Parsing your response :
Parsing a SOAP response can be as simple as this :
Parsing a Json Odata response can be as simple as this :
I think there is one "trick & tip". When you have to pass data directly to Navision tables and this integration will be doing programmers who aren't known well Nav it's good to make kind of integration tables.
In integration tables structure is the same as in original table, but integration tables doesn't have any restrictions on fields. As a c# programmer I think about it as sth like DTO.
What are the advantages of integration tables?
As you can know in Navision is many of restrictions and fields dependencies. It's important which field you fill first, on which field you should use VALIDATE etc.
In my opinion this is very comfortable for a c#, php, generally non-dynamics programmers who can pass data do Dynamics Nav without any problems and they doesn't have to think about this Nav restrictions. They can do their job, pass data to Dynamics and in Dynamics we can decide how this data should be handled.
This solution also gives us separated "integration" and Dynamics Nav logic what will save us a lot of time in future modifications.
Here some useful links:
How can Dynamics NAV interoperate with business-specific third-party applications using webservices:
Microsoft Dynamics NAV (Navision) Communities: