I was also getting the same error, the WCF was working properly for me when i was using it in the Dev Environment with my credentials, but when someone else was using it in TEST, it was throwing the same error.
I did a lot of research, and then instead of doing config updates, handled an exception in the WCF method with the help of fault exception.
Also the identity for the WCF needs to be set with the same credentials which are having access in the database, someone might have changed your authority.
Please find below the code for the same:
[ServiceContract]
public interface IService1
{
[OperationContract]
[FaultContract(typeof(ServiceData))]
ForDataset GetCCDBdata();
[OperationContract]
[FaultContract(typeof(ServiceData))]
string GetCCDBdataasXMLstring();
//[OperationContract]
//string GetData(int value);
//[OperationContract]
//CompositeType GetDataUsingDataContract(CompositeType composite);
// TODO: Add your service operations here
}
[DataContract]
public class ServiceData
{
[DataMember]
public bool Result { get; set; }
[DataMember]
public string ErrorMessage { get; set; }
[DataMember]
public string ErrorDetails { get; set; }
}
in your service1.svc.cs you can use this in the catch block:
catch (Exception ex)
{
myServiceData.Result = false;
myServiceData.ErrorMessage = "unforeseen error occured. Please try later.";
myServiceData.ErrorDetails = ex.ToString();
throw new FaultException<ServiceData>(myServiceData, ex.ToString());
}
And use this in the Client application like below code:
ConsoleApplicationWCFClient.CCDB_HIG_service.ForDataset ds = obj.GetCCDBdata();
string str = obj.GetCCDBdataasXMLstring();
}
catch (FaultException<ConsoleApplicationWCFClient.CCDB_HIG_service.ServiceData> Fex)
{
Console.WriteLine("ErrorMessage::" + Fex.Detail.ErrorMessage + Environment.NewLine);
Console.WriteLine("ErrorDetails::" + Environment.NewLine + Fex.Detail.ErrorDetails);
Console.ReadLine();
}
Just try this, it will help for sure to get the exact issue.