IM new on this forum, so bare with me if i posted this in the wrong forum.
Here goes...
I have been trying all sorts of ways to consume this web-service i have been given. Ill try and show you what i do to get where i am atm.
1. i start by adding the service reference in VS. everything goes as intended, i can see all the methods given to me.
2. to access the methods, and hopefully get some data, i do the following:
BMGWS ws = new BMGWS();
Vogn vogn = new Vogn();
VognType ty = new VognType();
NetworkCredential cred = new NetworkCredential("username","Password","domain");
ws.PreAuthenticate = true;
ws.Credentials= cred;
ws.SendVogn("BMG 2013", true, ref vogn);
foreach (VognType c in vogn.Vogn1)
{
Console.WriteLine(c.RegNr);
}
i get the following error: HTTP-status 401: Unauthorized.
I can say that the service i consume have a bunch of methods, only one method return a string, rest return void. the method that returns a string is working perfectly, but the "void" methods are not, im abit confused about that, so if anyone could shet some light on this i would get really happy.
any help would be much apreciated, since im kinda stuck
regards Majestic
Answers
How does the URL look like that you added as Web-Reference?
Do you mind just trying ws.usedefaultcredentials = true?
i added a webservice by right clicking on my solution and chose "add webservice", and clicking advanced and adding a web referernce.
thereafter i get alot of services/methods added that i can use, as i explain above, there is only one method that sends somthing in return, my checkLogin method gives me a string in return if its a correct login that has been parsed. the other methods returns void eg nothing, that is confuesing to me.
Anyhow i tried what you said about the "ws.usedefaultcredentials = true" and it seems like it works with my login method. but does still not work with the rest of the methods.
my code atm looks like this:
my checklogin() works well, tho my ws.sendvogn() does not :-k - Its supposed to send me some 3 tables of data from NAV
At the moment i dont get any errors when building, but i get absolutly nothing in return from NAV.
If i add the service without adding it as a web reference, but as a normal Service refernce, i cant get my loginmethod to work... i get the error: The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'NTLM’
i use this code for my normal service reference:
hope you can help!
here is the XML of the SendVogn:
there was no test data in the database with the Bool value true, changed it to false and it worked, my working code looks like this:
it works perfectly!