web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

In MS CRM 2016 plugin external .svc service consumed in console is fine but do not get consumed in plugin when triggering ocreate()

(0) ShareShare
ReportReport
Posted on by

ERRO:  "Could not find default endpoint element that references contract 'CaseInfo.ACX_CaseTableQService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element."

C# FILE:

CaseInfo.AxdACX_CaseTableQ ObjCasetableQ = new CaseInfo.AxdACX_CaseTableQ();

CaseInfo.AxdEntity_Acx_CaseTable_1 objAxd = new CaseInfo.AxdEntity_Acx_CaseTable_1();
objAxd.Zipcode = "110035";
objAxd.CustomerCode = "D4Z7PBxSLwwHWUC";
objAxd.Address1 = "EFWE,keshavpuram,DL,IND";
ObjCasetableQ.Acx_CaseTable_1 = new CaseInfo.AxdEntity_Acx_CaseTable_1[1]
{
objAxd
};

CaseInfo.EntityKey[] ReturnKey = Proxy.create(cnx, ObjCasetableQ);

}

APP.CONFIG:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<!--<appSettings>
<add key="ServerURL" value=""/>
<add key="Username" value=""/>
<add key="Password" value=""/>
</appSettings>-->
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_ACX_CaseTableQService" />
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://url"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_ACX_CaseTableQService"
contract="CaseInfo.ACX_CaseTableQService" name="NetTcpBinding_ACX_CaseTableQService">
<identity>
<userPrincipalName value="administrator@techdomain.com
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Andreas Cieslik Profile Picture
    9,267 on at

    Hi,

    you need to create the binding on the fly in your C# code as explained here:

    nishantrana.me/.../calling-wcf-service-in-plugin-in-crm

  • Community Member Profile Picture
    on at

    I dont want to use WCF, i m just doing in normal plugin by extending IPlugin interface.

    i did not get what "fly" is.

    Can you show me what code i need to change in my code?

  • Suggested answer
    Andreas Cieslik Profile Picture
    9,267 on at

    You need to replace your configuration XML with a C# code version as shown in this article:

    docs.microsoft.com/.../message-security-with-a-windows-client

  • Community Member Profile Picture
    on at

    but this config file is coming from thrd party webservice.

  • Community Member Profile Picture
    on at

    so i can just eliminate config or i just need to add more code in my C# code to avoid this error.

  • Andreas Cieslik Profile Picture
    9,267 on at

    instead of the config file you need to implement the configuration in C# code

  • Community Member Profile Picture
    on at

    FACING PROBLEM IN THIS, CANT UNDERSTAND WHAT IS CALCLATOR.. KINDLY RELATE WITH MY ABOVE CODE

    ServiceHost myServiceHost = new ServiceHost

       (typeof(Calculator), netTcpUri);

    myServiceHost.AddServiceEndpoint(

       typeof(ICalculator), binding, "");

    // Open the service.

    myServiceHost.Open();

  • Community Member Profile Picture
    on at

    using System;

    using System.Collections.Generic;

    using Microsoft.Xrm.Sdk;

    using Microsoft.Xrm.Sdk.Client;

    using System.Linq;

    using System.Web;

    using System.Runtime.Serialization;

    using System.ServiceModel.Description;

    using Microsoft.Xrm.Sdk.Query;

    using System.Configuration;

    using System.Text;

    using System.Threading.Tasks;

    using Basic_plugin.CaseInfo;

    namespace Basic_plugin

    {

       public class Class1 : IPlugin

       {

           public void Execute(IServiceProvider serviceProvider)

           {

               ITracingService traceObj = (ITracingService)serviceProvider.GetService(typeof(ITracingService));

               IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

               IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));

               IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

               Entity entity = (Entity)context.InputParameters["Target"];

               if (entity.LogicalName == "e011_cases")

               {

                   try

                   {

                       //IOrganizationService service = GetOrganization();

                       QueryExpression qetwo = new QueryExpression

                       {

                           EntityName = "e11_cas",

                           ColumnSet = new ColumnSet(true)

                       };

                       qetwo.Criteria.AddCondition("e011_caseid", ConditionOperator.Equal, "ADI00194");

                       EntityCollection ectwo = service.RetrieveMultiple(qetwo);

                       string caseid = ectwo.Entities[0].Attributes["e011_caseid"].ToString();

                       string companycode = ectwo.Entities[0].Attributes["e011_companycode"].ToString();

                       String weborderid = String.Empty;

                       if (ectwo.Entities[0].Contains("new_weborderidnew"))

                       {

                           weborderid = ((EntityReference)ectwo.Entities[0].Attributes["new_weborderidnew"]).Name;

                       }

                       //    string casecategoryid = ectwo.Entities[0].Attributes["e011_caseid"].ToString();

                       DateTime casedate = Convert.ToDateTime(ectwo.Entities[0].Attributes["createdon"].ToString());

                       //var nameRef = (Microsoft.Xrm.Sdk.EntityReference)ectwo.Entities[0].Attributes["new_weborderidnew"];

                       //var actualName = service.Retrieve(nameRef.LogicalName, nameRef.Id, new ColumnSet(true));

                       //string weborderid = actualName["new_name"].ToString();

                       //   string websaleslineid = ectwo.Entities[0].Attributes["e011_caseid"].ToString();

                       //   string state = ectwo.Entities[0].Attributes["e011_caseid"].ToString();

                       //   string zipcode = ectwo.Entities[0].Attributes["e011_caseid"].ToString();

                       //   string calltype = ectwo.Entities[0].Attributes["e011_calltype"].ToString();

                       CaseInfo.ACX_CaseTableQServiceClient Proxy = new CaseInfo.ACX_CaseTableQServiceClient();

                       CaseInfo.CallContext cnx = new CaseInfo.CallContext();

                       cnx.Company = "1100";

                       Proxy.ClientCredentials.Windows.ClientCredential.UserName = "administrator";

                       Proxy.ClientCredentials.Windows.ClientCredential.Domain = "ad";

                       Proxy.ClientCredentials.Windows.ClientCredential.Password = "@42";

                       CaseInfo.AxdACX_CaseTableQ ObjCasetableQ = new CaseInfo.AxdACX_CaseTableQ();

                       CaseInfo.AxdEntity_Acx_CaseTable_1 objAxd = new CaseInfo.AxdEntity_Acx_CaseTable_1();

                       objAxd.CaseID = caseid;

                       objAxd.CaseDate = casedate;

                       objAxd.CaseCategoryId = "C0005";

                       objAxd.State = "DL";

                       objAxd.CaseSubType = CaseInfo.AxdEnum_Acx_CaseSubType.NDR;// ACX_CaseTableQ.AxdEnum_Acx_CaseSubType.COD ;

                       // objAxd.CaseSubTypeSpecified = true;

                       objAxd.CaseStatus = CaseInfo.AxdEnum_Acx_CaseStatus.Open;// ACX_CaseTableQ.AxdEnum_Acx_CaseSubType.COD ;

                       objAxd.CaseStatusSpecified = true;

                       objAxd.CaseType = CaseInfo.AxdEnum_Acx_CaseType.Inbound;// ACX_CaseTableQ.AxdEnum_Acx_CaseSubType.COD ;

                       // objAxd.CA = true;

                       objAxd.RefundPaymentMethod = CaseInfo.AxdEnum_ACX_RefundPaymentMethod.Cheque;// ACX_CaseTableQ.AxdEnum_Acx_CaseSubType.COD ;

                       objAxd.RefundPaymentMethodSpecified = true;

                       objAxd.CompanyCode = "11";

                       objAxd.RefWebOrderID = "11568224";

                       objAxd.RefWebSalesLineID = "ITEM1503489096289159290";

                       objAxd.Zipcode = "110035";

                       objAxd.CustomerCode = "D4Z7PBxSLwwHWUC";

                       objAxd.Address1 = "EFWE,keshavpuram,DL,IND";

                       ObjCasetableQ.Acx_CaseTable_1 = new CaseInfo.AxdEntity_Acx_CaseTable_1[1]

                   {

                       objAxd

                   };

                       CaseInfo.EntityKey[] ReturnKey = Proxy.create(cnx, ObjCasetableQ);

                   }

                   catch (Exception ex)

                   {

                       traceObj.Trace("Plugin Exception : {0}", ex.ToString());

                       traceObj.Trace("Plugin Ends With No Excepption");

                   }

               }

           }

       }

    }

    This is my Config

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
    <system.serviceModel>
    <bindings>
    <netTcpBinding>
    <binding name="NetTcpBinding_ACX_CaseTableQService" />
    </netTcpBinding>
    </bindings>
    <client>
    <endpoint address="net.tcp://url"
    binding="netTcpBinding" bindingConfiguration="NetTcpBinding_ACX_CaseTableQService"
    contract="CaseInfo.ACX_CaseTableQService" name="NetTcpBinding_ACX_CaseTableQService">
    <identity>
    <userPrincipalName value="administrator@AAIN.com" />
    </identity>
    </endpoint>
    </client>
    </system.serviceModel>
    </configuration>

  • Verified answer
    Andreas Cieslik Profile Picture
    9,267 on at

    More appropriate sample is this:

    docs.microsoft.com/.../transport-security-with-windows-authentication

    Which translates into something like that:

    // Create the binding.

    NetTcpBinding myBinding = new NetTcpBinding();

    myBinding.Security.Mode = SecurityMode.Transport;

    myBinding.Security.Transport.ClientCredentialType =

       TcpClientCredentialType.Windows;

    // Create the endpoint address.

    EndpointAddress myEndpointAddress = new

       EndpointAddress("net.tcp://url");

    // Create the client

    CaseInfo.ACX_CaseTableQServiceClient Proxy = new CaseInfo.ACX_CaseTableQServiceClient(myBinding, myEndpointAddress);

  • Community Member Profile Picture
    on at

    Thank you  Sir, it is fixed but now catch block caught an exception

    " Request for the permission of type 'System.Security.Permissions.EnvironmentPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.  "

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans