i m a newbie on webservices, this is a webservice using “http wsdl” which is a SAP webservice and this is then code that is working fine when called from asp.net, but the same code when used in C# windows application give me unauthorized error.
WebService.CustomerService CustObj = new WebService.CustomerService(); //object NetworkCredential ntkCred = new NetworkCredential(System.Configuration.ConfigurationManager.AppSettings["UserName"].ToString(), System.Configuration.ConfigurationManager.AppSettings["PassWord"].ToString()); CredentialCache credCache = new CredentialCache(); //username and pwd from web.config credCache.Add(new Uri("[URL="http://xxx.com:xxxx/CustomerService?wsdl=1.1"]http://xxx.com:xxxx/CustomerService?wsdl=1.1[/URL]" ), "Basic", ntkCred); CustObj.Credentials = credCache; CustObj.GetCustomerDetails("00000000", "", "Username", out objCust); //webservice function
i am unable to assign the “CredentialCache” object to my webservice object like this CustObj.Credentials = credCache; in C# the intellisence doesn’t show the “Credential” method instead it shows a “ClientCredentials” property.
and this is the error i m getting:
System.ServiceModel.Security.MessageSecurityException: The HTTP request is unauthorized with client authentication scheme 'Anonymous'.The authentication header received from the server was 'Basic realm="SAP Web Application Server [SAPDS]".--->System.Net .WebException: The remote server returned an error:(401)Unauthorized. at System.Net.HttpWebRequest.GetResponse() at System.ServiceModel.channels.HttpChannelFactory.HttpRequestChannel.HttpChannelReques.WaitForReply(TimeSpan timeout)