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 the
NavWebService.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 of
NavWebService.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.
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 example
using 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.
Comments
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 the 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 of and use this in its place:
I think the NetworkCredential constructor also takes your domain name as a third parameter if needed.
Tim Larson
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 example
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?
I have since copied the exe file to a mobile device and it is now working OK
Thanks for your help
Graham