Using MS Dynamics NAV with PHP [closed]

对着背影说爱祢 提交于 2020-01-02 19:29:07

问题


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…


回答1:


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 :

<add key="ServicesUseNTLMAuthentication" value="true" />

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 :

// Create curl handle
$ch = curl_init(); 

// Set HTTP options
curl_setopt($ch, CURLOPT_URL, $url);  
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);   
curl_setopt($ch, CURLOPT_USERPWD, 'username:password'); 

// Get & output response (= XML or Json string)
echo curl_exec($ch);

// Close handle
curl_close($ch);

Step 3 : Parsing your response :

Parsing a SOAP response can be as simple as this :

 $data = simplexml_load_string(str_ireplace(['SOAP-ENV:', 'SOAP:'], '', $response));

Parsing a Json Odata response can be as simple as this :

$data = json_decode($response);



回答2:


Here some useful links:

How can Dynamics NAV interoperate with business-specific third-party applications using webservices:

  1. Microsoft Dynamics NAV Web Services: MSDN
  2. Talking with Navision: Exposing .NET Components to Navision: MSDN

Microsoft Dynamics NAV (Navision) Communities:

  1. http://community.dynamics.com/product/nav/f/34.aspx
  2. http://www.mibuso.com/



回答3:


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.



来源:https://stackoverflow.com/questions/8886017/using-ms-dynamics-nav-with-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!