将 MS Dynamics NAV 与 PHP 结合使用

发布于 2024-12-27 03:11:27 字数 1539 浏览 4 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

神爱温柔 2025-01-03 03:11:27

如何从 PHP 连接 Navision 的 Web 服务

步骤 1:检查您的配置

您需要确保在 CustomSettings.config 文件中启用 NTLM:

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

步骤 2:在 OData 和 SOAP 之间进行选择

由于 Microsoft Dynamics NAV 2009 年,Microsoft Dynamics NAV 除了 SOAP Web 服务之外还支持 OData Web 服务。就我个人而言,我发现 Odata 协议比 SOAP 协议直观得多。

OData 还具有额外的优势,即支持 Json 而不是 XML 来进行服务器和客户端之间的通信,这使得标准 PHP 数组或对象之间的转换变得非常简单。

请参阅官方 MSDN 文档 了解有关在何处查找现有 Web 服务列表(带有相应 URL)以及如何注册新服务的更多信息。


步骤 3:发送 HTTP 请求:

如果您要使用 SOAP,您可能需要使用 PHP 的 SoapClient一些第三方库基于它来发送和接收SOAP消息。

但是,如果您知道如何在 PHP 中解析 XML,则可以使用 cURL 并自行解析 XML 响应。或者,如果您选择 Odata 协议,则可以改用 Json 消息。 SOAP 只是 XML。

无论如何,如果您使用 cURL,则向 SOAP 或 Odata 服务发送 GET 请求实际上可以像这样简单:

// 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);

步骤 3:解析您的响应:

解析 SOAP 响应可以像这样简单:

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

解析 Json Odata 响应可以像这样简单:

$data = json_decode($response);

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);
眼泪都笑了 2025-01-03 03:11:27

这里有一些有用的链接:

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/

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/
岁月静好 2025-01-03 03:11:27

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

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

积分表有哪些优点?

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

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

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文