public static MetadataService.MetadataService GetMetaService()
{
#region for Online
CrmDiscoveryService.CrmDiscoveryService discoveryService = new CrmDiscoveryService.CrmDiscoveryService();
discoveryService.Url = String.Format("https://{0}/MSCRMServices/2007/{1}/CrmDiscoveryService.asmx", "dev.crm.dynamics.com", "Passport");
RetrievePolicyRequest policyRequest = new RetrievePolicyRequest();
RetrievePolicyResponse policyResponse = (RetrievePolicyResponse)discoveryService.Execute(policyRequest);
LogonManager lm = new LogonManager();
string passportTicket = lm.Logon(ConfigurationSettings.AppSettings["CRMUserName"], ConfigurationSettings.AppSettings["CRMPassword"], "crm.dynamics.com", policyResponse.Policy, "Production");
lm.Dispose();
RetrieveCrmTicketRequest crmTicketRequest = new RetrieveCrmTicketRequest();
crmTicketRequest.OrganizationName = ConfigurationSettings.AppSettings["Organization"];
crmTicketRequest.PassportTicket = passportTicket;
RetrieveCrmTicketResponse crmTicketResponse = (RetrieveCrmTicketResponse)discoveryService.Execute(crmTicketRequest);
MetadataService.MetadataService mdService =new CLMApplication.MetadataService.MetadataService();
mdService.Url = crmTicketResponse.OrganizationDetail.CrmMetadataServiceUrl;
MetadataService.CrmAuthenticationToken token = new MetadataService.CrmAuthenticationToken();
token.AuthenticationType = AuthenticationType.Passport;
token.CrmTicket = crmTicketResponse.CrmTicket;
token.OrganizationName = crmTicketResponse.OrganizationDetail.OrganizationName;
mdService.CrmAuthenticationTokenValue = token;
//CrmService myService = objConfig.RetrieveService();
//CreateDynamiceEntity(mdService, myService);
#endregion
return mdService;
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment