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 :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Client credential in consuming service

(0) ShareShare
ReportReport
Posted on by

Hi Experts,

I have consumed the webservice in ax 2009 and able invoke all classes and methods ,by creating a reference in vs.They provided the url with basic authentication. My question is do i need to hardcode the username and pwd in config file  or  in endpoint if so how? .At the time of creating a service reference i gave the credentials copied the .dll in client and server (both the dll and config).

Kindly guide me if i am following the wrong steps

Thanks,

Anbu

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

    It's stored in the configuration file by default, but you can also set credentials in code. This will allow you store them in an table and when you need to change them, you'll do it through GUI.

  • Community Member Profile Picture
    on at

    Hi Martin,

    1)I created a service reference and build it in vs. I copied the dll and config file to client and server bin folder (ax32.exe,ax32serv.exe).I modified the config file in vs to allow as Basic( <transport clientCredentialType="Basic" proxyCredentialType="None").

    2)I tested the url by creating the console application and hardcoded some of the values to execute the method ,I got 2errors (trustconnection with tls/ssl issue,client credentials is missing),i fixed those errors by hardcoding the client username and password and the other error " System.Net.ServicePointManager.ServerCertificateValidationCallback +=

               (se, cert, chain, sslerror) =>

               {

                  return true;

               };" by pasting the above code in console application and so my process execute successfully by getting a response back from the other application.

    3)In AOT i consumed the same service and invoke the classes and methods , when i debug the execute method i dont find any changes happening in the background , In the same place the error caught in vs because of the client credential and ssl/tls trust relationship .

    My question how i can open the connection to access the client application.I have used CLRInterop as well.

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

    Aha, so you didn't add a service reference to AOT. Then the configuration file will be ignored and you need to set everything in code.

    I don't understand your problem description ("i dont find any changes happening in the background , In the same place the error caught in vs because of the client credential and ssl/tls trust relationship"), but if it means that you want to implement the same logic as you did in Visual Studio (whatever it means), why don't you add it to the DLL?

    Note that bypassing security checks isn't generally considered a wise idea.

  • Community Member Profile Picture
    on at

    you didn't add a service reference to AOT-Yes.

    1)How to set everything in code.

    2)Inside my code when i try to invoke a client .When i debug this line client_getresponse(xml),it enter into the catch statement but I am not sure about how to get the exact error.I simple put an info statement ( info(CLRInterop::getLastException().tostring());) inside catch so i am getting only CLRObject as error.How to capture the exact error

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

    1) The solution depends on what exactly you mean by "everything". Here is a simple example:

    BasicHttpBinding binding = new BasicHttpBinding();
    EndpointAddress address = new EndpointAddress("http://myHost/myService");
    MyServiceClient client = new MyServiceClient(binding, address);

    If you need more details, first search the web, because there is both WCF documentation and many discussion threads covering WCF. If you don't find the answer, tell us what exactly you need.

    2) Use info(AifUtil::getClrErrorMessage()) instead.

  • Community Member Profile Picture
    on at

    The error  I got in catch is "The username is not provided. Specify username in ClientCredentials".

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

    What you should do sounds clear - specifying username in ClientCredentials.

    If you don't know how, look at the link I gave you in my first reply.

  • Community Member Profile Picture
    on at

    Yes, its clear in C#,how to handle in x++

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

    You'd use exactly the same objects and properties as in C#, it's just more cumbersome in X++, because CLR Interop has several limitations.

    Therefore my recommendation is not doing it in X++ at all. Do it in C#. Create a public method in your assembly, which you'll call from X++. Add parameters for values that you'll pass from X++. And that just do the work in C#.

    Trying to re-implement it in X++ means spending extra time to get uglier code. It doesn't sound like a good idea to me.

  • Community Member Profile Picture
    on at

    I followed the link community.dynamics.com/.../windows-credentials-in-aif-service-client

    But in AX2009 I dont find the below method createServiceclient.

    Can you help me on this.

    serviceClient = AifUtil::createServiceClient(serviceClientType);

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 456 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 429 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans