Web Services Changes for Microsoft Dynamics NAV 2009 SP1

Microsoft Dynamics Nav 2009

The following enhancements and improvements to Web services functionality in Microsoft Dynamics NAV 2009 have been included for the SP1 release:

Standard encoding for company name has been updated

Microsoft Dynamics NAV 2009 SP1 uses a standard encoding algorithm to represent special characters in company names as part of a URL. For example, "CRONUS USA, Inc." is displayed as "CRONUS%20USA%2C%20Inc."

Company name Encoded version





You do not need to use encoding when typing a company name in a browser's Address bar or when typing a Web reference in Visual Studio. You can type the company name with spaces and special characters, or you can type the company name with encoding. Company names are always displayed with special characters when you view URLs.

This change affects the return values for the Companies function in the SystemService service, which returns unencoded company names in clear text. You can no longer use the output from the Companies function to build your URL. You must provide the encoded version of the company name. The advantage is that company names are now available in clear text (for example to be used in UIs). Always encode clear text company names if you are using them as part of a URL.

The new encoding is not destructive: you can encode and decode the company name and always get the same result. Another advantage is that company names can now be used to build URLs to start the RoleTailored client.

There is no backward compatibility with the pre-SP1 version of Microsoft Dynamics NAV 2009, so attempts to access Web services with a URL from that version will fail. To fix this problem, change the company name encoding.

Schema changes have been made in ReadMultiple and UpdateMultiple

Microsoft Office InfoPath could not modify multiple records using Microsoft Dynamics NAV page-based Web services because of a schema incompatibility. In Microsoft Dynamics NAV 2009 SP1, the schema for these operations has been updated. If you are using proxy-based Web services with Add Service Reference in Visual Studio 2008, or Add Web Reference in Visual Studio 2005, then you should update the reference. If you are using XML Web services, then you may need to modify the code that is used to parse the XML.

Updating records in page-based Web services only updates the fields that you actually changed

You can use Visual Studio to create a reference to a Web service. For example, you can get strongly typed access to customers and sales orders through pages.

Visual Studio autogenerates a <fieldname>Specified Boolean property for all nonstring fields that are received from Microsoft Dynamics NAV. In the pre-SP1 version of Microsoft Dynamics NAV 2009, a Web service would update all fields where <fieldname>Specified was true or where a string was not NULL. A NULL string value does not mean to clear the field. Instead, it means to not update the field. If you want to clear a field, then you set the value to String.Empty (“”).

In some cases, this implementation caused problems. For example, when you read a customer record to change the name, it was returned from the Get function with all <fieldname>Specified properties set to true and all string fields having content. To change the name of a customer, you must write to the Name field. Because the Searchname field is included in the data that is sent to a Web service, it would be updated, and the Name and Searchname fields could be out of sync. To update this field, you would need to set all other fields to NULL or <fieldname>Specified to false.

In Microsoft Dynamics NAV 2009 SP1, Visual Studio still uses <fieldname>Specified and string field <> NULL to determine what is sent, but only the changed fields are persisted. You can now execute code such as the following example, which only updates the name of the Customer field:

Customer customer = custService.Read("10000"); 
customer.Name = "The Cannon Group, Inc."; 
custService.Update(ref customer); 

Creating and updating sales orders through a page-based Web service has changed

The procedure for creating and updating sales orders through a page-based Web service has changed. For more information, see the Handling Sales Orders from Page based Web Services – in NAV 2009SP1 (and RTM) blog post.

Web services do not change the user's default company

In the pre-SP1 version of Microsoft Dynamics NAV 2009, a Web service consumer application would change the user's default company because Web services did not use the concept of a default company. Also, a Web service consumer application could not call a Web service operation to request the default company. In Microsoft Dynamics NAV 2009 SP1, invoking a Web service operation does not change the default company.

BLOB fields in page-based Web services are ignored

In the pre-SP1 version of Microsoft Dynamics NAV 2009, you could not have a BLOB field on any page that you exposed as a Web Service. In Microsoft Dynamics NAV 2009 SP1, the content of the BLOB is not transferred to the Web service consumer. The field is ignored.

If you want access to the value of the BLOB, then you must write some code. For more information, see Transferring binary data to/from WebServices (and to/from COM (Automation) objects).

Codeunits ignore operations with unsupported parameters

Codeunits can now be exposed as Web services even if they contain operations that use parameter types that are not supported by Web services. Such functions are not exposed as operations. Examples of such operations are streams, Automation, and BLOBs.

Connections from either PHP or Java are now supported

In Microsoft Dynamics NAV 2009 SP1, you can use PHP, Java, or other products that use the Simple and Protected GSSAPI Negotiation Mechanism (SPNEGO) to initiate a Web services connection to Microsoft Dynamics NAV.

If the RoleTailored client, Microsoft Dynamics NAV Server, and SQL Server database are all on separate computers, then you must set the WebServicesUseNTLMAuthentication parameter to true in the CustomSettings.config file, which is the Microsoft Dynamics NAV Server configuration file, before connecting from PHP or Java. See Configuring Microsoft Dynamics NAV Server.

See Also

Community Additions