Web services 如何连接到CRM IFD web服务?

Web services 如何连接到CRM IFD web服务?,web-services,dynamics-crm,dynamics-crm-4,Web Services,Dynamics Crm,Dynamics Crm 4,我从SDK中获取了代码,只做了一次修改来设置身份验证类型,但是当我尝试连接时,我得到了一个“未经授权”的错误 我的代码是: // Set up the CRM Service. CrmAuthenticationToken token = new CrmAuthenticationToken(); token.AuthenticationType = 2; token.OrganizationName = "TESTCRM"; CrmService service = new CrmServ

我从SDK中获取了代码,只做了一次修改来设置身份验证类型,但是当我尝试连接时,我得到了一个“未经授权”的错误

我的代码是:

// Set up the CRM Service.
CrmAuthenticationToken token = new CrmAuthenticationToken();
token.AuthenticationType = 2;
token.OrganizationName = "TESTCRM";


CrmService service = new CrmService();
service.Url = "https://testcrm.ifdtestsystem.com/MSCrmServices/2007/CrmService.asmx";
service.CrmAuthenticationTokenValue = token;
//service.Credentials = System.Net.CredentialCache.DefaultCredentials;
service.Credentials = new NetworkCredential("Bill", "Password");


// Create an account entity and assign data to some attributes.
account newAccount = new account();
newAccount.name = "Greg Bike Store";
newAccount.accountnumber = "123456";
newAccount.address1_postalcode = "98052";
newAccount.address1_city = "Redmond";


// Call the Create method to create an account.
Guid accountId = service.Create(newAccount);
使用SPLA(IFD)时,您还需要使用crmticket填充令牌。可以通过查询CrmDiscoveryService来检索票证

包含如何使用CrmDiscoveryService获取票证和设置CrmService的合理示例

请注意,不再需要该服务的凭据属性,因为所有身份验证信息都将在票据中

希望这有帮助