Hello All, I am new to Dynamics CRM web services, I want to consume web service from a console application, it's working from my local but when it goes to production server it's not working as the production server requires a proxy to set up before calling the web service. Can somebody explain how to use a proxy before calling the web service, this is the code which is working in my local machine over the internet
private static void ConnectToDynamics()
{
string odataUrl = _dynamicsURL;
string appId = Id;
string clientSecret = _secret;
AuthenticationParameters authArg = AuthenticationParameters.CreateFromResourceUrlAsync(new Uri(odataUrl)).Result;
AuthenticationContext authCtx = new AuthenticationContext(authArg.Authority);
AuthenticationResult authRes = authCtx.AcquireTokenAsync(authArg.Resource, new ClientCredential(appId, clientSecret)).Result;
using (OrganizationWebProxyClient webProxyClient = new OrganizationWebProxyClient(new Uri(odataUrl), false))
{
webProxyClient.HeaderToken = authRes.AccessToken;
using (OrganizationServiceContext ctx = new OrganizationServiceContext((IOrganizationService)webProxyClient))
{
var accounts = (from i in ctx.CreateQuery("entity") orderby i["name"] select i).Take(100);
foreach (var account in accounts)
Console.WriteLine(account["name"]);
}
}
}