locked
(CRM 4.0) SDK CrmService.Retrieve Exception RRS feed

  • Question

  • Hi everyone,

     

    I need the new reference to set a many to many relationship in version 4.0.

     

    Could someone please tell me what I am doing wrong? 

     

    The exception occurs where the text is bolded in the code sample.

     

    I have checked the SDK     - sdk\server\reference\cs\crmservice\serviceretrieve.cs

    - sdk\server\reference\cs\mics\associateentities.cs

     

     

    Code Sample

    using CrmSdk;

    //The web reference is
    //http://localhost:5555/MSCRMServices/2007/CrmService.asmx

    private void addMyRelation(Guid myEntityId)
    {

    CrmService service = new CrmService();
    service.Credentials = System.Net.CredentialCache.DefaultCredentials;

         
    new_MyEntity obMyEntity = (new_MyEntity)service.Retrieve(EntityName.new_MyEntity.ToString(), myEntityId, new AllColumns());

    Moniker moniker1 = new Moniker();
    moniker1.Name = "new_MyEntity ";

    moniker1.Id = new Guid(myEntityId.ToString());

           

    Moniker moniker2 = new Moniker();       

    moniker2.Name = "new_MyOtherEntity";   

    moniker2.Id = new Guid(myOtherEntityId.ToString());

           

    AssociateEntitiesRequest request = new AssociateEntitiesRequest();

           

    request.Moniker1 = moniker1;       

    request.Moniker2 = moniker2;       

    request.RelationshipName = "new_new_myEntity_new_myOtherEntity";

          

    service.Execute(request);

    }

     

    This is the exception:

     

    Exception Details: System.Web.Services.Protocols.SoapException: System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: http://schemas.microsoft.com/crm/2007/WebServices/Retrieve.
      at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()
      at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message)
      at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
      at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)

    Thursday, February 28, 2008 1:16 AM

Answers

All replies

  • Hi everyone,

     

    For anyone else encountering the same problem this was the fix:

     

    CrmAuthenticationToken token = new CrmAuthenticationToken();
    token.AuthenticationType = 0;      

    token.OrganizationName = "MyOrgName";  

        

    CrmService service = new CrmService();   

    service.Url = "http://localhost:5555/mscrmservices/2007/crmservice.asmx";
    service.CrmAuthenticationTokenValue = token;      

    service.Credentials = System.Net.CredentialCache.DefaultCredentials;

     

    I was not setting up the service correctly.

     

    Thursday, February 28, 2008 2:02 AM
  • Hi Optimus,

     

    You have used Moniker above in your code. May I know what is that used for?

    Thank you.

    Thursday, February 28, 2008 7:56 AM
  • Hi SlimGees,

     

    Monkier is used in CRM 4.0 for adding records to relationships.

     

    This link will explain more:

    http://blogs.msdn.com/crm/archive/2008/02/14/crm-4-0-relationships-explained.aspx

    Wednesday, March 5, 2008 11:36 PM