2

我正在启动一个外联网项目,其中 php 页面应该将数据发送到 Microsoft Dynamics NAV。

我以前没有使用过 NAV,但我在这里找到了一些信息。

示例 php 代码对我来说看起来很清楚,但是在开始这个项目之前我应该​​知道任何提示或技巧(基础知识)吗?欢迎所有示例......</p>

4

3 回答 3

5

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);
于 2016-02-18T20:16:03.097 回答
2

这里有一些有用的链接:

Dynamics NAV 如何使用 Web 服务与特定于业务的第三方应用程序进行互操作:

  1. Microsoft Dynamics NAV Web 服务:MSDN
  2. 与 Navision 交谈:向 Navision 公开 .NET 组件:MSDN

Microsoft Dynamics NAV (Navision) 社区:

  1. http://community.dynamics.com/product/nav/f/34.aspx
  2. http://www.mibuso.com/
于 2012-03-04T17:20:13.257 回答
0

我认为有一个“技巧和提示”。当您必须将数据直接传递到 Navision 表并且这种集成将做那些不熟悉 Nav 的程序员时,最好制作一种集成表。

集成表中的结构与原始表中的相同,但集成表对字段没有任何限制。作为 ac# 程序员,我认为它就像 DTO 一样。

集成表的优点是什么?

正如您在 Navision 中所知道的那样,有许多限制和字段依赖项。首先填写哪个字段,应该在哪个字段上使用 VALIDATE 等很重要。

在我看来,这对于 ac#、php、通常可以传递数据的非动态程序员来说非常舒服,他们可以毫无问题地进行动态导航,他们不必考虑这个导航限制。他们可以完成他们的工作,将数据传递给 Dynamics,在 Dynamics 中我们可以决定如何处理这些数据。

该解决方案还为我们提供了分离的“集成”和动态导航逻辑,这将为我们在未来的修改中节省大量时间。

于 2014-10-24T13:51:09.950 回答