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 AX (Archived)

Endpoint error when using web service via C#-Projekt Service Reference

(0) ShareShare
ReportReport
Posted on by 1,650

Hello together,

I'm trying to consume a web service via a C#-Project in AX 2012 (included as a service reference). When running the web service I'm getting the following error:

Could not find default endpoint element that references contract 'CustomerService.CustomerService' 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.

From my point of view the app.config looks alright:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
       <configSections>
       </configSections>
    <system.serviceModel>
        <bindings>
                <binding name="CustomerServiceSoap" closeTimeout="00:01:00" openTimeout="00:01:00"
                    receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
                    bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <security mode="Transport">
                        <transport clientCredentialType="None" proxyCredentialType="None"
                            realm="" />
                        <message clientCredentialType="UserName" algorithmSuite="Default" />
                    </security>
                </binding>
                <binding name="CustomerServiceSoap1" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <security mode="None">
                        <transport clientCredentialType="None" proxyCredentialType="None"
                            realm="" />
                        <message clientCredentialType="UserName" algorithmSuite="Default" />
                    </security>
                </binding>
            </basicHttpBinding>
            <customBinding>               
            </customBinding>
        </bindings>
        <client>           
            <endpoint address="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
                binding="basicHttpBinding" bindingConfiguration="CustomerServiceSoap"
                contract="CustomerService.CustomerServiceSoap" name="CustomerServiceSoap" />
        </client>
    </system.serviceModel>
</configuration>

 

Any help appreciated.

Sebastian

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    237,805 Most Valuable Professional on at

    Your configuration refers to contract CustomerService.CustomerServiceSoap, not CustomerService.CustomerService.

  • Sebastian Aurand Profile Picture
    1,650 on at

    Thanks for the fast response. Unfortunatly I posted the wrong error message. The correct one is:

    Could not find endpoint element with name ‘CustomerServiceSoap’ and contract ‘CustomerService.CustomerServiceSoap’ 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 name could be found in the client element.

    Here is the line of code "calling the configuration":

    CustomerServiceSoapClient customerService = new CustomerServiceSoapClient("CustomerServiceSoap");

    Any ideas? I'm not realy familiar which element in the configuration file is referencing to another one and therefore should have the same name.

    Sebastian

  • Martin Dráb Profile Picture
    237,805 Most Valuable Professional on at

    I've now opened the configuration in XML editor and I see that it is not a well-formed XML at all - there is no opening tag for </basicHttpBinding>. I would even expect that the application would not start in such case, i.e. that you config is completely ignored.

    If you just made a class library project and call it from AX, it doesn't load any configuration by itself. You have to handle the configuration in code or include it in AOS's config (Ax32Serv.exe.config). I currently don't use the latter approach but I believe it worked for me as well.

  • Sebastian Aurand Profile Picture
    1,650 on at

    Thanks again. My config file is well-formed. I only deleted sections, which are not relevant (at least I hope) for this error.

    How do you have to handle the app.config in AX 2012 when the C#-Projekt is set to "Deploy to client".

    I'm not shure it will work if I integrate the app.config in the Ax32Serv.exe.config. Is there a client file as well?

    To be on the safe side here is the complete app.config:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
     <configSections>
     </configSections>
        <system.serviceModel>
            <bindings>
                <basicHttpBinding>
                    <binding name="BingPortBinding" closeTimeout="00:01:00" openTimeout="00:01:00"
                        receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
                        bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                        maxBufferSize="5242880" maxBufferPoolSize="524288" maxReceivedMessageSize="5242880"
                        messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                        useDefaultWebProxy="true">
                        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                        <security mode="None">
                            <transport clientCredentialType="None" proxyCredentialType="None"
                                realm="" />
                            <message clientCredentialType="UserName" algorithmSuite="Default" />
                        </security>
                    </binding>
                    <binding name="BasicHttpBinding_IGeocodeService" closeTimeout="00:01:00"
                        openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                        allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                        maxBufferSize="5242880" maxBufferPoolSize="524288" maxReceivedMessageSize="5242880"
                        messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                        useDefaultWebProxy="true">
                        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                        <security mode="None">
                            <transport clientCredentialType="None" proxyCredentialType="None"
                                realm="" />
                            <message clientCredentialType="UserName" algorithmSuite="Default" />
                        </security>
                    </binding>
                    <binding name="BasicHttpBinding_IRouteService" closeTimeout="00:01:00"
                        openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                        allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                        maxBufferSize="5242880" maxBufferPoolSize="524288" maxReceivedMessageSize="5242880"
                        messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                        useDefaultWebProxy="true">
                        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                        <security mode="None">
                            <transport clientCredentialType="None" proxyCredentialType="None"
                                realm="" />
                            <message clientCredentialType="UserName" algorithmSuite="Default" />
                        </security>
                    </binding>
                    <binding name="CustomerServiceSoap" closeTimeout="00:01:00" openTimeout="00:01:00"
                        receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
                        bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                        maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                        messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                        useDefaultWebProxy="true">
                        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                        <security mode="Transport">
                            <transport clientCredentialType="None" proxyCredentialType="None"
                                realm="" />
                            <message clientCredentialType="UserName" algorithmSuite="Default" />
                        </security>
                    </binding>
                    <binding name="CustomerServiceSoap1" closeTimeout="00:01:00"
                        openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                        allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                        maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                        messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                        useDefaultWebProxy="true">
                        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                        <security mode="None">
                            <transport clientCredentialType="None" proxyCredentialType="None"
                                realm="" />
                            <message clientCredentialType="UserName" algorithmSuite="Default" />
                        </security>
                    </binding>
                </basicHttpBinding>
                <customBinding>
                    <binding name="CustomBinding_IGeocodeService">
                        <binaryMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
                            maxSessionSize="2048">
                            <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                                maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                        </binaryMessageEncoding>
                        <httpTransport manualAddressing="false" maxBufferPoolSize="524288"
                            maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous"
                            bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard"
                            keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous"
                            realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
                            useDefaultWebProxy="true" />
                    </binding>
                    <binding name="CustomBinding_IRouteService">
                        <binaryMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
                            maxSessionSize="2048">
                            <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                                maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                        </binaryMessageEncoding>
                        <httpTransport manualAddressing="false" maxBufferPoolSize="524288"
                            maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous"
                            bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard"
                            keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous"
                            realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
                            useDefaultWebProxy="true" />
                    </binding>
                </customBinding>
            </bindings>
            <client>
                <endpoint address="http://api.bing.net:80/soap.asmx" binding="basicHttpBinding"
                    bindingConfiguration="BingPortBinding" contract="BingV2ServiceReference.BingPortType"
                    name="BingPort" />
                <endpoint address="http://dev.virtualearth.net/webservices/v1/geocodeservice/GeocodeService.svc"
                    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IGeocodeService"
                    contract="BingMapsGeocode.IGeocodeService" name="BasicHttpBinding_IGeocodeService" />
                <endpoint address="http://dev.virtualearth.net/webservices/v1/geocodeservice/GeocodeService.svc/binaryHttp"
                    binding="customBinding" bindingConfiguration="CustomBinding_IGeocodeService"
                    contract="BingMapsGeocode.IGeocodeService" name="CustomBinding_IGeocodeService" />
                <endpoint address="http://dev.virtualearth.net/webservices/v1/routeservice/routeservice.svc"
                    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IRouteService"
                    contract="BingMapsRoute.IRouteService" name="BasicHttpBinding_IRouteService" />
                <endpoint address="http://dev.virtualearth.net/webservices/v1/routeservice/routeservice.svc/binaryHttp"
                    binding="customBinding" bindingConfiguration="CustomBinding_IRouteService"
                    contract="BingMapsRoute.IRouteService" name="CustomBinding_IRouteService" />
                <endpoint address="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
                    binding="basicHttpBinding" bindingConfiguration="CustomerServiceSoap"
                    contract="CustomerService.CustomerServiceSoap" name="CustomerServiceSoap" />
            </client>
        </system.serviceModel>
    </configuration>

  • Martin Dráb Profile Picture
    237,805 Most Valuable Professional on at

    Sorry, I was slightly confused regarding what you want to achieve. In your case, I don't see any way how to use physical configuration files - the usual way is to save configuration to database and load it in code.

  • Verified answer
    Sebastian Aurand Profile Picture
    1,650 on at

    In order to solve the problem of not having the configuration available at runtime. I came up with a solution (not the most elegant one, but it's running). I implemented the configuration in the C#-Code:

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    #region

     

     

     

    Create configuration

     

     

     

    BasicHttpBinding binding = new BasicHttpBinding();

    binding.Name =

     

    "CustomerServiceSoap";

    binding.CloseTimeout = System.

     

    TimeSpan.Parse("00:01:00");

    binding.OpenTimeout = System.

     

    TimeSpan.Parse("00:01:00");

    binding.ReceiveTimeout = System.

     

    TimeSpan.Parse("00:10:00");

    binding.SendTimeout = System.

     

    TimeSpan.Parse("00:01:00");

    binding.AllowCookies =

     

    false;

    binding.BypassProxyOnLocal =

     

    false;

    binding.HostNameComparisonMode = System.ServiceModel.

     

    HostNameComparisonMode.StrongWildcard;

    binding.MaxBufferSize = 65536;

    binding.MaxBufferPoolSize = 524288;

    binding.MaxReceivedMessageSize = 65536;

    binding.MessageEncoding = System.ServiceModel.

     

    WSMessageEncoding.Text;

    binding.TextEncoding = System.Text.

     

    Encoding.UTF8;

    binding.TransferMode = System.ServiceModel.

     

    TransferMode.Buffered;

    binding.UseDefaultWebProxy =

     

    true;

    binding.ReaderQuotas.MaxDepth = 32;

    binding.ReaderQuotas.MaxStringContentLength = 8192;

    binding.ReaderQuotas.MaxArrayLength = 16384;

    binding.ReaderQuotas.MaxBytesPerRead = 4096;

    binding.ReaderQuotas.MaxNameTableCharCount = 16384;

    binding.Security.Mode = System.ServiceModel.

     

     

    BasicHttpSecurityMode.Transport;

    binding.Security.Transport.ClientCredentialType =

     

    HttpClientCredentialType.None;

    binding.Security.Transport.ProxyCredentialType =

     

    HttpProxyCredentialType.None;

    binding.Security.Transport.Realm =

     

    "";

    binding.Security.Message.ClientCredentialType =

     

    BasicHttpMessageCredentialType.UserName;

    binding.Security.Message.AlgorithmSuite = System.ServiceModel.Security.

     

    SecurityAlgorithmSuite.Default;

     

     

     

    EndpointAddress endpoint = new EndpointAddress("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");

    #endregion

     

     

     

    // Webservice to be called

     

     

     

    CustomerServiceSoapClient customerService = new CustomerServiceSoapClient(binding, endpoint);

  • Community Member Profile Picture
    on at

    I have same problem. Now I have found this article:

    technet.microsoft.com/.../hh500185.aspx

    "To use or modify the application configuration file in a C# project by using C# code to consume external web services, you should use the .NET Framework class ConfigurationChannelFactory. For more information, see Configuration Channel Factory."

    I will try this way too.

  • Suggested answer
    Community Member Profile Picture
    on at

    For those who work with AX 2012 AIF services and try to call there C# or VB project inside AX (x++) and suffer from such errors of "could not find default endpoint"... or "no contract found" ... stop AX client, then go back to your visual studio (c#) project and add these lines (C# code added below) before declaring your service client, then deploy the project and restart AX client and retry: Note, the example is for NetTcp adapter, you could easily use any other adapter instead according to your need.

     Uri Address = new Uri("net.tcp://your-server:Port>/DynamicsAx/Services/your-port-name");
     NetTcpBinding Binding = new NetTcpBinding();
     EndpointAddress EndPointAddr = new EndpointAddress(Address);
     SalesOrderServiceClient Client = new SalesOrderServiceClient(Binding, EndPointAddr);

  • Suggested answer
    Martin Dráb Profile Picture
    237,805 Most Valuable Professional on at

    The thread is five years old, but as Abdullah re-open it, let me add something...

    Using code is always a possibility, and you usually want to modify parts of the configuration, such as having the endpoint address in database. Nevertheless it's possible to load the configuration file itself with the help of AifUtil::CreateServiceClient(), therefore setting everything by code isn't necessary.

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 AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans