Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

ExecuteTransactionRequest CRM 2015 update 0.2 failed

$
0
0

Hello,

MS CRM version : 2015 update 0.2

I have executed the ExecuteTransactionRequest but i returns an exception:

The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameterschemas.microsoft.com/.../Services:request. The
 InnerException message was 'Error in line 1 position 451. Element'schemas.microsoft.com/.../Services:request'
contains data from a type that maps to the name'schemas.microsoft.com/.../Contracts:ExecuteTransactionRequest'.
 The deserializer has no knowledge of any type that maps to this name.
Consider changing the implementation of the ResolveName method on your
DataContractResolver to return a non-null value for name'ExecuteTransactionRequest' and namespace'schemas.microsoft.com/.../Contracts'.'

This is the source code:

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xrm.Sdk.Messages;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Xrm.Sdk;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.Runtime.Serialization;
using Microsoft.Crm.Sdk.Messages;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            OrganizationRequestCollection orgRequestCol = new OrganizationRequestCollection();

            //from configuration file;
            string serverLogin = "Administrateur";
            string serverPwd = "Operating0";
           // string serviceEndPointUrl = "crm2015/.../Organization.svc";// System.Configuration.ConfigurationManager.AppSettings["ServiceEndPointUrl"];
            //string serverCrmUrl ="crm2015/.../Organization.svc";// System.Configuration.ConfigurationManager.AppSettings["ServerCrmUrl"];
            string OrganizationUri = "crm2015/.../Organization.svc";

            Uri organizationUriIFD = new Uri(OrganizationUri);
            ClientCredentials credentials = new ClientCredentials();
            credentials.UserName.UserName = serverLogin;
            credentials.UserName.Password = serverPwd;
            //credentials.UserName.
            IServiceConfiguration<Microsoft.Xrm.Sdk.IOrganizationService> config = ServiceConfigurationFactory.CreateConfiguration<Microsoft.Xrm.Sdk.IOrganizationService>(organizationUriIFD);
            OrganizationServiceProxy serviceP = new OrganizationServiceProxy(config, credentials);
            // This statement is required to enable early-bound type support.

            serviceP.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());
            serviceP.EnableProxyTypes();
           Entity entContact = null;

            CreateRequest createRequest;
            for (int intCount = 0; intCount < 3; intCount++)
            {
                entContact = new Entity("contact");
                entContact["name"] = string.Format("Test Contact {0}", intCount);
                createRequest = new CreateRequest() { Target = entContact };
                orgRequestCol.Add(createRequest);
            }
            ExecuteTransactionRequest execTrans = new ExecuteTransactionRequest()
            {
                ReturnResponses = true,
                Requests = orgRequestCol
            };
            ExecuteTransactionResponse response = (ExecuteTransactionResponse)serviceP.Execute(execTrans);
        }
    }
}

Thanks for help.


Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>