Hi Andrew,
Same error from console app also. The following is the full code that I have written in console app
IOrganizationService service = CrmService.InitializeServiceProxy();
//Initialize Binding
BasicHttpsBinding hBind = new BasicHttpsBinding();
hBind.Security.Mode = BasicHttpsSecurityMode.Transport;
hBind.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
hBind.MessageEncoding = WSMessageEncoding.Text;
hBind.MaxReceivedMessageSize = int.MaxValue;
// Retrieve Service url from Config entity
Uri webServiceUrl = new Uri(serverURL);
//Intialize ServiceClient on Address
EndpointAddress eAddress = new System.ServiceModel.EndpointAddress(webServiceUrl);
QuoteLine_Create_OutClient serviceClient = new QuoteLine_Create_OutClient(hBind, eAddress);
// Retrieve credentials from config entity
serviceClient.ClientCredentials.UserName.UserName = userName;
serviceClient.ClientCredentials.UserName.Password = password;
QueryExpression getWebResource = new QueryExpression("webresource");
getWebResource.ColumnSet = new ColumnSet(new string[] { "name", "content" });
getWebResource.Criteria.AddCondition(new ConditionExpression("name", ConditionOperator.Equal, webResourceName));
EntityCollection webResources = service.RetrieveMultiple(getWebResource);
if (webResources.Entities.Count > 0)
{
Entity webResource = webResources.Entities[0];
byte[] clientCertificate = Convert.FromBase64String(webResource.Attributes["content"].ToString());
X509Certificate2 _clientCert = new X509Certificate2(clientCertificate);
if (_clientCert != null)
{
serviceClient.ClientCredentials.ClientCertificate.Certificate = _clientCert;
}
}
Any suggestions?