locked
How to use strongly typed class in Dynamics CRM 2011 without using sdk assemblies RRS feed

  • Question

  • I'm trying to retrieve data from crm 2011 in the same way I did with 4.0, with strongly typed class and using crm webservices (wsdl/soap) only.

    I achieve this using Entity class (DynamicEntity substitute) and generic attributes with OrganizationServiceClient.RetriveMultiple(), or using the OData OrganizationData.svc endpoint (WCF Data Service).

    But I want to do that using pure webservice (xml/soap http post on *.svc) and using generated entities from my crm data model, and not using dynamic entity, like I always did in CRM 4.0. I need that for a customer who need to consume dynamics crm using pure webservices and strongly typed class (without OData)

    What I'm missing or confused?

    Questions:

    1. It's possible to generate strongly typed class from .svc without using any crm sdk assemblies(/crmsvcutil) ?
    2. It's possible to generate strongly typed class without using OData Protocol and without using any crm sdk assemblies ? 

    I'm a bit confused with this big changes. I can't clarify my questions using crm 2011 sdk documentation.

    Thanks.


    -- Christophe Trevisani Chavey www.notafiscaldeservicos.com.br www.virtualgroup.com.br
    Wednesday, June 29, 2011 2:04 AM

Answers

  • I'm being told directly from Microsoft that the WSDL generation from the 2007 endpoint in CRM 2011 should work exactly as it did in CRM 4.0:

    http://<servername[:port]>/mscrmservices/2007/crmservice.asmx?WSDL&uniquename=organizationName


    Dave Berry - MVP Dynamics CRM - http:\\crmentropy.blogspot.com Please follow the forum guidelines when inquiring of the dedicated CRM community for assistance.
    Wednesday, June 29, 2011 7:27 PM
    Moderator
  • Christophe - Dave is correct. One thing to  be aware is that you do not get any of the new functionality that we added in CRM 2011 - For instance if you use the CRM 2011 endpoint. you can work with .NET types , batch create/update requests of an entity and its related records in a single message , new query capabilities like getting attributes from related entities in a single Query, LINQ and many others.

    The WSDL from CRM 2011 WCF endpoint is static and does not contain any of the strong types, you can generate the new types using CrmSvcUtil and use them along with the XRM SDK. You would need .NET 4.0 and the ability to reference the XRM SDK assembly in your environment.

    Is this not possible when developing from TIBCO?

     

    Thursday, June 30, 2011 7:24 PM

All replies

  • Wednesday, June 29, 2011 5:35 AM
    Moderator
  • Thanks for the reply but this dont use strongly typed class. I already read that.

    I'm almost assuming that it is not possible to use strongly typed class (class Account, Lead, new_MyCustomEntity, Oportunity...) using only pure soap endpoint (webservice) without using crm assemblies (xrm.sdk...) or without using OData endpoint (OrganizationData.svc), for get this typed class.

     

    Very strange. Nobody can help?

     

    Thanks!


    -- Christophe Trevisani Chavey www.notafiscaldeservicos.com.br www.virtualgroup.com.br
    Wednesday, June 29, 2011 12:37 PM
  • The CRM 2011 wdsl does not include the full data model for strongly typed entities. This was to speed up the connection to the web services.

    The crmsvcutil.exe builds the classes, but this requires the assemblies. I guess the easiest way is to build your our own strongly typed classes for attribute names, picklist values etc. You would write an app to build these using the metadata service quite easily.

    Wednesday, June 29, 2011 12:54 PM
  • Yes, in 4.0 we generate our entities and "abstract entities" but in this crm 2011, a customer need to use soap protocol to comunicate from TIBCO (a biztalk derivate).

     

    He need exactly the same method crm 4.0 provide, but its seems to not existing anymore using soap endpoint, only OData.

     


    -- Christophe Trevisani Chavey www.notafiscaldeservicos.com.br www.virtualgroup.com.br
    Wednesday, June 29, 2011 4:45 PM
  • The 2007 SOAP endpoints still exist in CRM 2011 for backward compatibility, so you can use the same CRM 4.0 code in CRM 2011, if you must.
    Dave Berry - MVP Dynamics CRM - http:\\crmentropy.blogspot.com Please follow the forum guidelines when inquiring of the dedicated CRM community for assistance.
    Wednesday, June 29, 2011 5:38 PM
    Moderator
  • Yes, but this older endpoint doesnt send the entity model anymore.
    -- Christophe Trevisani Chavey www.notafiscaldeservicos.com.br www.virtualgroup.com.br
    Wednesday, June 29, 2011 6:14 PM
  • I'm being told directly from Microsoft that the WSDL generation from the 2007 endpoint in CRM 2011 should work exactly as it did in CRM 4.0:

    http://<servername[:port]>/mscrmservices/2007/crmservice.asmx?WSDL&uniquename=organizationName


    Dave Berry - MVP Dynamics CRM - http:\\crmentropy.blogspot.com Please follow the forum guidelines when inquiring of the dedicated CRM community for assistance.
    Wednesday, June 29, 2011 7:27 PM
    Moderator
  • I'm being told directly from Microsoft that the WSDL generation from the 2007 endpoint in CRM 2011 should work exactly as it did in CRM 4.0:

    http://<servername[:port]>/mscrmservices/2007/crmservice.asmx?WSDL&uniquename=organizationName


    Dave Berry - MVP Dynamics CRM - http:\\crmentropy.blogspot.com Please follow the forum guidelines when inquiring of the dedicated CRM community for assistance.

    Oh yes! with your URL its working fine, like expected. I tried with a url like this one but was a little different.

    Thank you!

     

    But in 2011, definitively, we can't do the same thinks using the new interfaces without assemblies/crmsvcutil and not using odata?

     


    -- Christophe Trevisani Chavey www.notafiscaldeservicos.com.br www.virtualgroup.com.br
    Wednesday, June 29, 2011 7:42 PM
  • From what I know about CRM 2011, you appear to be correct.  The end-point model was revamped for speed and computational efficiency, and in doing so the strong-typing is not inherently available to the WSDL generated therefrom.  To achieve that, you'd basically have to write up your own classes (much like the CrmSvcUtil does) that derive from Entity and assume local member values from the Entity members.  Again, I don't have any experience yet with writing 2011 code, so I'm probably not a great help here.  I was simply trying to give you a good option for working around the apparent inadequacies of 2011 in the face of your requirements.
    Dave Berry - MVP Dynamics CRM - http:\\crmentropy.blogspot.com Please follow the forum guidelines when inquiring of the dedicated CRM community for assistance.
    Wednesday, June 29, 2011 8:01 PM
    Moderator
  • Christophe - Dave is correct. One thing to  be aware is that you do not get any of the new functionality that we added in CRM 2011 - For instance if you use the CRM 2011 endpoint. you can work with .NET types , batch create/update requests of an entity and its related records in a single message , new query capabilities like getting attributes from related entities in a single Query, LINQ and many others.

    The WSDL from CRM 2011 WCF endpoint is static and does not contain any of the strong types, you can generate the new types using CrmSvcUtil and use them along with the XRM SDK. You would need .NET 4.0 and the ability to reference the XRM SDK assembly in your environment.

    Is this not possible when developing from TIBCO?

     

    Thursday, June 30, 2011 7:24 PM
  • Hi Mahesh,

    Sorry for the late answer, I was traveling (holidays :D). 

    The TIBCO's Consultant told me that he can't use .NET Assemblies, and he can't get the authentication and communication working with crm 2011 webservices. 

    We create a test program consuming crm 4 endpoint in crm2011, snif network packet and deliver the xml to Tibco consultant and it get the communication between them working fine.

    But the definitely solution is: we create a "intermediate webservice" that Tibco consume, so this tool will intermediate Tibco with crm2011 endpoint.

    The big problem was Tibco authenticating with CRM 2011 webservices.

    Thank you!


    -- Christophe Trevisani Chavey www.notafiscaldeservicos.com.br www.virtualgroup.com.br
    Friday, August 5, 2011 12:59 PM
  • This is code to get Organization Service for 3.5. Do not forget to add service reference for needed organization service(http://<servername>:<portnumber>/<organizationname>/XRMServices/2011/Organization.svc?wsdl). I use it for developing SSIS packages for SQL Server 2008.
    Uri orgURL = new Uri (stringURL);
    
    
                SymmetricSecurityBindingElement security = SecurityBindingElement.CreateSspiNegotiationBindingElement();
                security.DefaultAlgorithmSuite = SecurityAlgorithmSuite.Default;
                security.SecurityHeaderLayout = SecurityHeaderLayout.Strict;
                security.IncludeTimestamp = true;
                security.KeyEntropyMode = SecurityKeyEntropyMode.CombinedEntropy;
                security.MessageProtectionOrder = MessageProtectionOrder.SignBeforeEncryptAndEncryptSignature;
                security.MessageSecurityVersion = MessageSecurityVersion.WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10;
                security.LocalClientSettings.CacheCookies = true;
                security.LocalClientSettings.DetectReplays = true;
                security.LocalClientSettings.ReplayCacheSize = 900000;
                security.LocalClientSettings.MaxClockSkew = new TimeSpan(0, 5, 0);
                security.LocalClientSettings.MaxCookieCachingTime = new TimeSpan(23, 0, 0, 0);
                security.LocalClientSettings.ReplayWindow = new TimeSpan(0, 5, 0);
                security.LocalClientSettings.SessionKeyRenewalInterval = new TimeSpan(15, 0, 0);
                security.LocalClientSettings.SessionKeyRolloverInterval = new TimeSpan(0, 5, 0);
                security.LocalClientSettings.ReconnectTransportOnFailure = true;
                security.LocalClientSettings.TimestampValidityDuration = new TimeSpan(0, 5, 0);
                security.LocalClientSettings.CookieRenewalThresholdPercentage = 60;
                security.LocalServiceSettings.DetectReplays = true;
                security.LocalServiceSettings.IssuedCookieLifetime = new TimeSpan(10, 0, 0);
                security.LocalServiceSettings.MaxStatefulNegotiations = 128;
                security.LocalServiceSettings.ReplayCacheSize = 900000;
                security.LocalServiceSettings.MaxClockSkew = new TimeSpan(0, 5, 0);
                security.LocalServiceSettings.NegotiationTimeout = new TimeSpan(0, 1, 0);
                security.LocalServiceSettings.ReplayWindow = new TimeSpan(0, 5, 0);
                security.LocalServiceSettings.InactivityTimeout = new TimeSpan(0, 2, 0);
                security.LocalServiceSettings.SessionKeyRenewalInterval = new TimeSpan(15, 0, 0);
                security.LocalServiceSettings.SessionKeyRolloverInterval = new TimeSpan(0, 5, 0);
                security.LocalServiceSettings.ReconnectTransportOnFailure = true;
                security.LocalServiceSettings.MaxPendingSessions = 128;
                security.LocalServiceSettings.MaxCachedCookies = 1000;
                security.LocalServiceSettings.TimestampValidityDuration = new TimeSpan(0, 5, 0);
    
                TextMessageEncodingBindingElement textEncoding = new TextMessageEncodingBindingElement();
                textEncoding.MaxReadPoolSize = 64;
                textEncoding.MaxWritePoolSize = 16;
                textEncoding.MessageVersion = MessageVersion.Default;
                textEncoding.WriteEncoding = System.Text.Encoding.UTF8;
                    
                
    
                HttpTransportBindingElement httpTransport = new HttpTransportBindingElement();
                httpTransport.ManualAddressing = false;
                httpTransport.MaxBufferSize = 65536;
                httpTransport.MaxReceivedMessageSize = 65536;
                httpTransport.AllowCookies = false;
                httpTransport.AuthenticationScheme = AuthenticationSchemes.Anonymous;
                httpTransport.BypassProxyOnLocal = false;
                httpTransport.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
                httpTransport.KeepAliveEnabled = true;
                httpTransport.MaxBufferPoolSize = 524288;
                httpTransport.ProxyAuthenticationScheme = AuthenticationSchemes.Anonymous;
                httpTransport.TransferMode = TransferMode.Buffered;
                httpTransport.UnsafeConnectionNtlmAuthentication = false;
                httpTransport.UseDefaultWebProxy = true;
                
    
                CustomBinding binding = new CustomBinding(new List<BindingElement> { security, textEncoding, httpTransport });
                EndpointAddress endpoint = new EndpointAddress(orgURL);
    
                OrganizationServiceClient client = new OrganizationServiceClient(binding, endpoint);
    
               
                
                
                
                IOrganizationService _orgservice = (IOrganizationService) client;

    Thursday, July 19, 2012 12:39 PM