Hello,
I have to write a C# app who insert a customer on a Retail channel database, using CRT (the app will actually do a lot more at the end, but I'm focus on this job currently).
I try to do it in the most simple way for now, times to understand how it works.
Some precisions to begin :
- I'm a complete novice on AX technologies.
- I haven't configure the retail channel (but I can ask our client for changes, or get details about configuration).
Here's my code :
void CreateCustomer()
{
long channelId = ***;
string connectionString = "Server=***;Database=***;User Id=***;Password=***";
var configSection = CommerceRuntimeConfigurationManager.GetConfigurationSection("commerceRuntime");
var commercePrincipal = new CommercePrincipal(new CommerceIdentity(channelId, Enumerable.Empty<string>()));
var runtime = CommerceRuntime.Create(new CommerceRuntimeConfiguration(configSection, connectionString, true), commercePrincipal);
CustomerManager customerManager = CustomerManager.Create(runtime);
Customer newCustomer = new Customer();
newCustomer.AccountNumber = "an unique account num";
newCustomer.PriceGroup = "a price group";
newCustomer.CustomerGroup = "a customer group";
newCustomer.Name = "name of customer";
// etc...
customerManager.CreateCustomer(newCustomer); // throw exception, see below
}
The exception I get is this :
--- CommunicationException ---
An unhandled exception of type 'Microsoft.Dynamics.Commerce.Runtime.CommunicationException' occurred in Microsoft.Dynamics.Commerce.Runtime.Workflow.dll
Additional information: Exception while calling invoke method NewCustomer:
No elements matching the key 'WSHttpBinding' were found in the configuration element collection.
And the StackTrace :
System.ServiceModel.Configuration.ServiceModelConfigurationElementCollection`1.get_Item(Object key)
System.ServiceModel.WSHttpBinding.ApplyConfiguration(String configurationName)
System.ServiceModel.WSHttpBinding..ctor(String configName)
Microsoft.Dynamics.Commerce.Runtime.TransactionService.TransactionServiceClientFactory.CreateBinding()
Microsoft.Dynamics.Commerce.Runtime.TransactionService.TransactionServiceClientFactory.DoRefresh()
Microsoft.Dynamics.Commerce.Runtime.TransactionService.TransactionServiceClientFactory.get_ChannelFactory()
Microsoft.Dynamics.Commerce.Runtime.TransactionService.TransactionServiceClientFactory.CreateTransactionServiceClient()
Microsoft.Dynamics.Commerce.Runtime.TransactionService.TransactionServiceClient.GetResponseFromMethod(String methodName, Object[] parameterList, Boolean useExtensionMethod)
It sounds like a WCF error, but as the Dynamics Retail Server is a black box to me, I don't know how to configure the client side (in the app.config). Any idea ?
Last precision : the CustomerManager works on the other side, the method GetCustomer() for example.
Here's the app.config and the commerceRuntime.config (provided by CRT's SDK, no changes) :
<configuration>
<configSections>
<section name="commerceRuntime" type="Microsoft.Dynamics.Commerce.Runtime.Configuration.CommerceRuntimeSection, Microsoft.Dynamics.Commerce.Runtime.ConfigurationProviders, Version=6.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
</configSections>
<commerceRuntime>
<storage defaultOperatingUnitNumber="" />
<query defaultPageSize="250" maxPageSize="5000" />
<cache disableCaching="false" disableCacheUpdates="false" forceCacheLookupHostile="false" forceCacheLookupMiss="false" forceCacheLookupHit="false" />
<composition>
<add source="assembly" value="Microsoft.Dynamics.Commerce.Runtime.Services" />
<add source="assembly" value="Microsoft.Dynamics.Commerce.Runtime.Services.Desktop, Version=6.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<add source="assembly" value="Microsoft.Dynamics.Commerce.Runtime.TransactionService, Version=6.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<add source="assembly" value="Microsoft.Dynamics.Commerce.Runtime.Workflow, Version=6.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<add source="assembly" value="Microsoft.Dynamics.Commerce.Runtime.DataServices, Version=6.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<add source="assembly" value="Microsoft.Dynamics.Commerce.Runtime.DataServices.SqlServer, Version=6.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<add source="assembly" value="Microsoft.Dynamics.Commerce.Runtime.DataAccess.SqlServer, Version=6.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<add source="assembly" value="Microsoft.Dynamics.Commerce.Runtime.Cache.MemoryCache, Version=6.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
</composition>
</commerceRuntime>
</configuration>
<configuration>
<commerceRuntime>
<storage defaultOperatingUnitNumber="" />
<query defaultPageSize="250" maxPageSize="5000" />
<cache disableCaching="false" disableCacheUpdates="false" forceCacheLookupHostile="false" forceCacheLookupMiss="false" forceCacheLookupHit="false" />
<composition>
<add source="assembly" value="Microsoft.Dynamics.Commerce.Runtime.Services" />
<add source="assembly" value="Microsoft.Dynamics.Commerce.Runtime.Services.Desktop, Version=6.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<add source="assembly" value="Microsoft.Dynamics.Commerce.Runtime.TransactionService, Version=6.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<add source="assembly" value="Microsoft.Dynamics.Commerce.Runtime.WorkflowFoundation, Version=6.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<add source="assembly" value="Microsoft.Dynamics.Commerce.Runtime.Workflow, Version=6.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<add source="assembly" value="Microsoft.Dynamics.Commerce.Runtime.DataServices, Version=6.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<add source="assembly" value="Microsoft.Dynamics.Commerce.Runtime.DataServices.SqlServer, Version=6.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<add source="assembly" value="Microsoft.Dynamics.Commerce.Runtime.DataAccess.SqlServer, Version=6.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<add source="assembly" value="Microsoft.Dynamics.Commerce.Runtime.Cache.MemoryCache, Version=6.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
</composition>
</commerceRuntime>
</configuration>
Any help would be appreciated !
Best regards,
Charles
*This post is locked for comments

Report
All responses (
Answers (