更新Ms Dynamics Nav服务引用遇401及NotSupportedException错误求解决
Alright, let's tackle those two issues you're hitting when updating service references in Microsoft Dynamics NAV—first that RecordReference error, then the widespread 401 Unauthorized messages. Here's what you can try to fix each one:
Fixing the
System.NotSupportedException (RecordReference) Error When you see that XML fault mentioning "RecordReference", it’s almost always because the NAV web service you’re trying to reference uses the RecordReference data type, which isn’t supported for direct service reference consumption. Here’s how to resolve it:
- Audit your published web service objects: Open the Dynamics NAV client, navigate to the Web Services page, and check the Page or Codeunit you’re publishing. Look for any fields, methods, or parameters that use the RecordReference type. Replace these with concrete record types (like
CustomerorVendor) or other supported data types (e.g., integers, strings) that serve the same purpose. - Update your NAV version: If you’re on an older Dynamics NAV release, this might be a known bug. Install the latest Cumulative Update (CU) for your version—Microsoft often patches issues related to web service type handling.
- Republish the web service: Sometimes the WSDL file gets corrupted. Unpublish the affected web service, save your changes, then republish it. Wait a minute for the server to regenerate the WSDL, then try updating your service reference again.
These are permission-related, so we’ll focus on verifying credentials and configuration settings:
- Validate user permissions: The account you’re using to access the web services needs two critical things:
- A Dynamics NAV permission set that includes Web Service Access (at minimum—you may need additional permissions for the specific objects you’re accessing).
- Access rights to the IIS application pool hosting the NAV web services.
- Match authentication methods: NAV web services support Windows, Username/Password, and OAuth authentication. Make sure your client setup matches the server’s configuration:
- For Windows auth: Ensure your machine is on the same domain as the NAV server, or use a domain account with valid access.
- For Username/Password auth: Update your service reference’s config file (app.config/web.config) to include the correct credentials in the
<system.serviceModel>section.
- Check IIS settings: Open IIS Manager, navigate to the NAV web service site:
- Confirm the application pool’s identity has access to the NAV server and its database.
- Enable the correct authentication method (e.g., Windows Auth) and disable unused ones (like Anonymous Auth) that might cause conflicts.
- Verify NAV Server config: In the Dynamics NAV Server Administration tool, check the web service settings to ensure the authentication method you’re using is enabled (e.g., allow Username/Password if you’re not using Windows auth).
- Clear cached credentials: Windows might store outdated or incorrect credentials. Go to Control Panel > Credential Manager, find any entries related to your NAV server, delete them, then re-enter your credentials when updating the service reference.
内容的提问来源于stack exchange,提问作者Alfred Kimotho
相关产品推荐
相关产品推荐

