开发者

SSIS 2008 - Connecting to CRM 2011 Web Service using the script component

I’m trying to connect to the CRM 2011 Web service endpoints from an SSIS 2008 Script component which can’t utilize .Net 4 assemblies. This rules out the .Net 4 SDK so I’ve been trying to create a proxy class to use to work directly against the 2011 WS. I’ve gotten the code to work by putting that proxy class into it's own assembly but it relies on reading the WS address from the app.config (method 1) which the SSIS packages can’t use (those user configurable attributes need to be stored in SSIS variables so the customer can modify them to work in their environment).

I'd like to figure out how to read app.config data from within a SSIS package...

Or I need to get something like method 2 working but am not sure why the server is throwing the error it does. The credentials are correct. The OrganizationServiceClient method has several overloads that I’ve tried and none have worked. This is the closest I’ve gotten to getting it working. Can anyone tell me what I’m doing wrong?

            //Method 1:  This code works but relies on pulling the endpoint add开发者_JAVA百科ress 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);

Part of the app.config below (used by method 1 above):

    <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>


Have you looked at using something like this approach within SSIS to read the App.config file and parse the XML doc to set variables in the SSIS package?

http://www.sqlservercentral.com/articles/Integration+Services+(SSIS)/69550/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜