Using Nav 2009 SP1 web service from a mobile device

GrahamHutchinson
Member Posts: 4
Does anybody have a C# example of using a Nav 2009 Web Service from a mobile device,without using Dynamics Mobile (Which has been discontinued) ?
I am having a problem with setting credentials to use the service.
I am having a problem with setting credentials to use the service.
0
Comments
-
Start off by reviewing this: http://dynamicsuser.net/blogs/navdev/ar ... rvice.aspx. It shows the general case for how to consume a Nav 2009 web service from C#.
The question you seem to be focusing on is with authentication to the web service - I'm guessing you're getting a HTTP 401 unauthorized error, or something similar.
There are two options here:
1. Set your C# application to run in the context of the user that has permissions on the web service, then use theNavWebService.usedefaultcredentials = true;
setting shown in the article referenced above.
However, if you're running on a mobile device, #1 could be tricky. So let's look at option #2
2. Get rid ofNavWebService.UseDefaultCredentials = true;
and use this in its place:NavWebService.UseDefaultCredentials = false; NavWebService.Credentials = new NetworkCredential("myUsername", "myPassword");
I think the NetworkCredential constructor also takes your domain name as a third parameter if needed.
Tim Larson0 -
Thanks for that Tim
I have tried doing what you suggested, but I am still unable to get a connection.
I am using the following code extracted from Lars Lohndorf-Larsen's exampleusing System; using System.Linq; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Reflection; using System.Net; namespace SmartDeviceProjectLars { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { WS.web NAVWebService = new WS.web(); NAVWebService.Credentials = new NetworkCredential("Name", "Pass"); textBox2.Text = NAVWebService.AddX(textBox1.Text); } } }
Because it is a smart device project "NavWebService.UseDefaultCredentials = false" is not available.
I have used the identical code in a windows application and it works perfectly.
Any other suggestions?0 -
I was using an emulator from visual studio to test this.
I have since copied the exe file to a mobile device and it is now working OK
Thanks for your help
Graham0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions