c# - calling https web service methods -


i have added web reference of web service url starts https. , trying call following c# code

testwebservices.basichttpbinding_gdataservice webservice = new testwebservices.basichttpbinding_gdataservice (); uri uri = new uri(webservice.url);             credentialcache cache = new credentialcache(); cache.add(uri, "negotiate", new networkcredential("username", "password", "domainname")); webservice.credentials = cache;  var response = webservice.getmethods(); return response; 

i getting following error

the request failed http status 401: unauthorized. 

i guess reason "basichttpsecuritymode has not been set transport" (which possible if add service reference). not find way set that. or cannot not achievable? vs.net 2005 project,

updated: have add following still having same error

webservice.usedefaultcredentials = true var response = webservice.getmethods(); 

working version : following code started work. @user469104

testwebservices.basichttpbinding_gdataservice webservice = new testwebservices.basichttpbinding_gdataservice (); webservice.credentials = new networkcredential("username", "password"); var response = webservice.getmethods(); 

the error getting not related https per se. 401 means whatever credentials making through server, if any, not authorized access service.

i guessing web service hosted iis? if so, , have control on it, verify 'integrated authentication' enabled (i assuming trying use since specifying 'negotiate') , make sure passing valid credentials. dj kraze said in comment, if trying pass domain credentials, make sure passing domain.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -