2011-07-27 3 views
0

J'essaie de me connecter aux points de terminaison du service Web CRM 2011 à partir d'un composant de script SSIS 2008 qui ne peut pas utiliser les assemblys .Net 4. Cela exclut le SDK .Net 4 donc j'ai essayé de créer une classe proxy à utiliser pour travailler directement contre le WS 2011. J'ai obtenu le code à travailler en mettant cette classe proxy dans son propre assembly mais il repose sur la lecture de l'adresse WS à partir du app.config (méthode 1) que les packages SSIS ne peuvent pas utiliser (ces attributs configurables par l'utilisateur doivent être stocké dans des variables SSIS afin que le client puisse les modifier pour fonctionner dans leur environnement).SSIS 2008 - Connexion au service Web CRM 2011 à l'aide du composant de script

Je voudrais savoir comment lire les données de app.config à partir d'un package SSIS ...

Ou je dois obtenir quelque chose comme méthode de travail 2, mais ne sais pas pourquoi le serveur est de lancer la erreur c'est le cas. Les informations d'identification sont correctes. La méthode OrganizationServiceClient a plusieurs surcharges que j'ai essayées et aucune n'a fonctionné. C'est le plus proche que j'ai eu pour le faire fonctionner. Quelqu'un peut-il me dire ce que je fais mal?

  //Method 1: This code works but relies on pulling the endpoint address from the app.config (SSIS can’t use this method) 
     //OrganizationServiceClient serviceClient = new OrganizationServiceClient("CustomBinding_IOrganizationService"); 
     //serviceClient.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential() { Domain="MyDomain", UserName="administrator", Password="*****" }; 

//Method 2: This method throws this error: 
//Could not connect to https:// MYSERVER/XrmServices/2011/Organization.svc. TCP error code 10061: No connection could be made because the target machine actively refused it. 
     string url = "https:// MYSERVER/XrmServices/2011/Organization.svc"; 
     BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport); 
     binding.MaxReceivedMessageSize = 2147483647; 
     OrganizationServiceClient serviceClient = new OrganizationServiceClient(binding, new EndpointAddress(url)); 
     serviceClient.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential() { Domain=" MyDomain ", UserName="administrator", Password="******" }; 

      //this code is common between the two techniques above 
     KeyValuePairOfstringanyType[] attributes = new KeyValuePairOfstringanyType[1]; 
     attributes[0] = new KeyValuePairOfstringanyType(); 
     attributes[0].key = "name"; 
     attributes[0].value = "MyTestAccount"; 

     Entity newAccount = new Entity(); 
     newAccount.LogicalName = "account"; 
     newAccount.Attributes = attributes; 
     serviceClient.Create(newAccount); 

Une partie du app.config ci-dessous (utilisé par la méthode 1 ci-dessus):

<client> 
     <endpoint address="http://MYSERVER/XRMServices/2011/Organization.svc" 
      binding="customBinding" bindingConfiguration="CustomBinding_IOrganizationService" 
      contract="IOrganizationService" name="CustomBinding_IOrganizationService"> 
      <identity> 
       <userPrincipalName value="*******" /> 
      </identity> 
     </endpoint> 
    </client> 

Répondre

Questions connexes