locked
How to use WCF with CRM4? RRS feed

  • Question

  • We just upgraded from CRM3 to CRM4. After updating the specifics of my code that queried CRM3 using WCF to use CRM4, I'm getting a "Server was unable to process request." fault exception from CRM. I get the same fault exception when I perform a Fetch, Execute, and WhoAmIRequest.

    The CRM server trace contains:

    >CrmSoapExtension detected non-CrmException - report will be sent to Watson:
    System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object.
       at Microsoft.Crm.Extensibility.MessageProcessor.Execute(PipelineExecutionContext context)
       at Microsoft.Crm.Extensibility.InternalMessageDispatcher.Execute(PipelineExecutionContext context)
       at Microsoft.Crm.Extensibility.ExternalMessageDispatcher.Execute(String messageName, Int32 primaryObjectTypeCode, Int32 secondaryObjectTypeCode, PropertyBag fields, CorrelationToken correlationToken, CallerOriginToken originToken, UserAuth userAuth, Guid callerId)
       at Microsoft.Crm.Sdk.CrmServiceInternal.Fetch(String namespaceName, String fetchXml, CorrelationToken correlationToken, CallerOriginToken originToken, UserAuth userAuth, Guid callerId)
       at Microsoft.Crm.Sdk.Crm2007.CrmService.Fetch(String fetchXml)
       --- End of inner exception stack trace ---

    To me, it appears that "Object reference not set to an instance of an object." is the most important part, but there's nothing telling me which object is not instantiated. I don't know if the object is in my code, CRM code, or a 3rd party plug-in on the CRM server.

    Here's the code I'm using to test a simple fetch. This and every other call to CRM via WCF is failing.
    CrmService.CrmServiceSoapClient client = new
    
     CrmServiceSoapClient();
    client.ClientCredentials.Windows.ClientCredential.Domain = MYDOMAINNAME;
    client.ClientCredentials.Windows.ClientCredential.UserName = MYUSERNAME;
    client.ClientCredentials.Windows.ClientCredential.Password = MYPASSWORD;
    client.ClientCredentials.Windows.AllowedImpersonationLevel =
           System.Security.Principal.TokenImpersonationLevel.Impersonation;
    
    CrmAuthenticationToken authToken = new
     CrmAuthenticationToken();
    authToken.AuthenticationType = 0;
    authToken.OrganizationName = MYORGNAME;
    authToken.CallerId = new
     Guid(MYSYSTEMUSERID);
    
    CallerOriginToken origToken = new
     CallerOriginToken();
    origToken.CallerOrigin = new
      WebServiceApiOrigin();
    
    CorrelationToken corrToken = new
      CorrelationToken();
    
    // Retrieve all accounts.
    
    
    string
      fetch1 = "<fetch mapping='logical'><entity name='account'><all-attributes/></entity></fetch>"
    ;
    
    // Fetch the results.
    
    
    string
      result1 = client.Fetch(authToken, origToken, corrToken, fetch1);
    

    I had this working fine in CRM3 and I've updated all of the app.config sections, updated the service reference, even built a completely standalone project from scratch to test this (that's where the above code comes from), but I always get the same error.

    I also can't test this via WCF Test Client because of that client doesn't pass on my authenication info.


    Tuesday, March 31, 2009 3:55 PM

Answers

  • I've spoken with our Microsoft CRM rep who spoke with a CRM SDK team member. They said that it wasn't possible to use Microsoft WCF with Microsoft CRM. There's some bug in CRM that they either don't understand or can't figure out. They hope to at least having it working in CRM v5. I still find this interesting that they did nothing in v3 and it worked fine and then probably tried to do something in v4 and it broke it.
    Tuesday, April 7, 2009 3:31 PM

All replies

  • I've spoken with our Microsoft CRM rep who spoke with a CRM SDK team member. They said that it wasn't possible to use Microsoft WCF with Microsoft CRM. There's some bug in CRM that they either don't understand or can't figure out. They hope to at least having it working in CRM v5. I still find this interesting that they did nothing in v3 and it worked fine and then probably tried to do something in v4 and it broke it.
    Tuesday, April 7, 2009 3:31 PM
  • Jim,

    Any updates on this? This has become an issue for me as Web References (i.e. non WCF client proxies) have a bug where they won't work in 64 bit processes. I am assuming WCF would work in 64 bit, but I can't create a working WCF client. It's a bit of a catch-22 situation.


    Thanks,
    -Joe
    Wednesday, May 13, 2009 7:28 AM
  • I spoke with our MS CRM rep who spoke with the MS CRM SDK web services tech lead. They said it wasn't possible to use WCF client code due to a bug in their WDSL code. They also said the services might work properly in CRM 5.0 and didn't expect to fix anything for 4.0.
    Wednesday, May 13, 2009 3:29 PM
  • Hi,

    Was this issue ever resolved?

    Cheers

    Jim McLay

    Monday, January 10, 2011 3:15 PM