是否有可能调用动态CRM 2011年底绑定WCF服务组织未经SDK - 直定制的绑定? [英] Is it possible to call Dynamics CRM 2011 late-bound WCF Organization service without the SDK - straight customized binding?

查看:186
本文介绍了是否有可能调用动态CRM 2011年底绑定WCF服务组织未经SDK - 直定制的绑定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现我想要叫纯WCF场景动态CRM WCF服务不依赖于SDK的辅助类。基本上,我想实施打击的动态CRM 2011 使用.NET Framework中唯一的本地WCF的支持。

I'm trying to implement a pure WCF scenario where I want to call Dynamics CRM WCF service without relying on the SDK helper classes. Basically, I would like to implement federated authentication against Dynamics CRM 2011 using only native WCF support from the .net framework.

我之所以'联合认证]丢这是我想港口此方案后,上到BizTalk。

The reason I'm doing this is that I would like to port this scenario later-on to BizTalk.

我已经成功地生成具有SvcUtil工具代理类,但政策的一部分,安全断言是不与配置架构兼容。 。SvcUtil工具建议建立从代码,而不是,这是我想做的结合

I've successfully generated proxy classes with SvcUtil, but the part of the policies and security assertions are not compatible with the configuration schema. SvcUtil suggests to build the binding from code instead, which is what I'm trying to do.

生成的代码是在这里:

        private static void CallWcf()
    {
        OrganizationServiceClient client = null;

        try
        {
            // Login Live.com Issuer Binding

            var wsHttpBinding = new WSHttpBinding();
            wsHttpBinding.Security = new WSHttpSecurity();
            wsHttpBinding.Security.Mode = SecurityMode.Transport;

            // Endpoint Binding Elements

            var securityElement = new TransportSecurityBindingElement();
            securityElement.DefaultAlgorithmSuite = SecurityAlgorithmSuite.TripleDes;
            securityElement.IncludeTimestamp = true;
            securityElement.KeyEntropyMode = SecurityKeyEntropyMode.CombinedEntropy;
            securityElement.MessageSecurityVersion = MessageSecurityVersion.WSSecurity11WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10;
            securityElement.SecurityHeaderLayout = SecurityHeaderLayout.Strict;

            var securityTokenParameters = new IssuedSecurityTokenParameters();
            securityTokenParameters.InclusionMode = SecurityTokenInclusionMode.AlwaysToRecipient;
            securityTokenParameters.ReferenceStyle = SecurityTokenReferenceStyle.Internal;
            securityTokenParameters.RequireDerivedKeys = false;
            securityTokenParameters.TokenType = null;
            securityTokenParameters.KeyType = SecurityKeyType.SymmetricKey;
            securityTokenParameters.KeySize = 192;
            securityTokenParameters.IssuerAddress = new EndpointAddress("https://login.live.com/extSTS.srf");
            securityTokenParameters.IssuerMetadataAddress = null;
            securityTokenParameters.DefaultMessageSecurityVersion = null;
            securityTokenParameters.IssuerBinding = wsHttpBinding;

            securityElement.EndpointSupportingTokenParameters.Signed.Add(securityTokenParameters);

            var textMessageEncodingElement = new TextMessageEncodingBindingElement();
            textMessageEncodingElement.MaxReadPoolSize = 64;
            textMessageEncodingElement.MaxWritePoolSize = 16;
            textMessageEncodingElement.MessageVersion = MessageVersion.Default;
            textMessageEncodingElement.WriteEncoding = System.Text.Encoding.UTF8;

            textMessageEncodingElement.ReaderQuotas.MaxStringContentLength = 8192;
            textMessageEncodingElement.ReaderQuotas.MaxArrayLength = 16384;
            textMessageEncodingElement.ReaderQuotas.MaxBytesPerRead = 4096;
            textMessageEncodingElement.ReaderQuotas.MaxNameTableCharCount = 16384;

            var httpsTransportElement = new HttpsTransportBindingElement();
            httpsTransportElement.ManualAddressing = false;
            httpsTransportElement.AuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous;

            CustomBinding binding = new CustomBinding();
            binding.Elements.Add(securityElement);
            binding.Elements.Add(textMessageEncodingElement);
            binding.Elements.Add(httpsTransportElement);

            client = new OrganizationServiceClient(binding, new EndpointAddress(EndpointUri));
            client.ClientCredentials.UserName.UserName = Username;
            client.ClientCredentials.UserName.Password = Password;
            client.Open();

            var columnSet = new schemas.microsoft.com.xrm._2011.Contracts.ColumnSet();
            var identifier = new Guid("fbf8240e-2c85-e011-ad55-1cc1de0878eb");

            columnSet.Columns = new string[] { "name" };
            var entity = client.Retrieve("account", identifier, columnSet);
        }

        finally
        {
            if (client != null)
                client.Close();
        }
    }



我是新来的联合身份验证和我有一个很难搞清楚许多可用的绑定之间的电位差,所以我会在这方面的任何帮助表示感谢。

I'm new to federated authentication and am having a hard time figuring out the potential differences between the many available bindings, so I would be grateful for any help in this regard.

推荐答案

它可能是可能的,但是非常复杂。我们不得不使用它搬到ADFS动力学一个项目,需要增加许多额外代码周围清新的标记(代码形式autorefreshsecuritytoken.cs,deviceidmanager.cs和toolserviceproxies.cs从SDK),并且还在使用SDK的一切。

It is probably possible, but hugely complicated. We had a project using Dynamics which moved to ADFS, and required adding lots of extra code around refreshing tokens (code form autorefreshsecuritytoken.cs, deviceidmanager.cs and toolserviceproxies.cs from the SDK) and that was still using the SDK for everything.

裸记住,您还需要安装在它是功能复制另一个加载操作系统windows.identification。

Bare in mind you also need windows.identification installed in the OS which is another load of functionality to copy.

最后,你总是可以只使用JustDecompile或类似的,看看有什么SDK在做什么。

In the end you can always just use JustDecompile or similar to see what the SDK is doing.

这篇关于是否有可能调用动态CRM 2011年底绑定WCF服务组织未经SDK - 直定制的绑定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆