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)

Invoking AX web service via C#

(0) ShareShare
ReportReport
Posted on by 15

Hi,

I am trying to connect to the AX web services. What I will do it to fetch the right price given a product and a customer.

I realised the right webservice to use is PriceListServiceClient and I am able to log in to it using windows authentication, but I cannot retrieve any data from it.

Here is my code:

PriceListServiceClient priceListServiceClient = new PriceListServiceClient();


priceListServiceClient.ClientCredentials.Windows.ClientCredential.UserName = "yyy";

priceListServiceClient.ClientCredentials.Windows.ClientCredential.Password = "zzz!";

priceListServiceClient.ClientCredentials.Windows.ClientCredential.Domain = "xxx";          

CriteriaElement[] criteriaElement = new CriteriaElement[1];

criteriaElement[0] = new CriteriaElement();

criteriaElement[0].DataSourceName = "SalesPrice";

criteriaElement[0].FieldName = "ItemId";

criteriaElement[0].Operator = Operator.NotEqual;

criteriaElement[0].Value1 = "5637153175"

QueryCriteria queryCriteria = new QueryCriteria();

queryCriteria.CriteriaElement = criteriaElement;

CallContext callContext = new CallContext();

            

var found = priceListServiceClient.find(callContext, queryCriteria);

Console.WriteLine(found.Currency);

priceListServiceClient.Close();

Any idea about why this is happening?

*This post is locked for comments

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

    Your query criteria don't seem to correspond to your requirements ("given a product and a customer"). Isn't that the problem?

    By the way, you can actually debug the service (PricePriceListService.find()) to see what exactly is happening there.

  • MarcoPie Profile Picture
    15 on at

    Hi Martin, thanks for the answer.

    You nare right, the idea was that, I relaxed the criterias hoping that would have helped. but it did not.

    I have enabled the remote debug on the server where the webservices are running, but I could not step into the intruction.

    Does the webervices leave any trace in the logs?¨

    Is there any alternative?

  • Joris dG Profile Picture
    17,775 on at

    The user you use to logon, does he have a default company setup? You may be trying to read data from the "DAT" company... you can also provide the company as part of your call context.

  • Suggested answer
    dolee Profile Picture
    11,279 on at

    Hi Marcopie,

    I found the doc on PriceList Document for AX2009 here. It also applies to AX2012.

    The Ax<Table> class for Price List document is AxPriceDiscTmpPrintout Class. This class wraps the TmpPriceDiscPrintout table, which is a TMP table. That's why you are not getting anything in return.

    To verify, you can change the TmpPriceDiscPrintout table to a regular table. Add a record in it and your code will be getting something back.

    Regards,

    Dominic

  • MarcoPie Profile Picture
    15 on at

    Hey Joris,

    I checked, the user I am using has the right company as default.

  • MarcoPie Profile Picture
    15 on at

    Hi Dominic,

    Your answer was quite enlightning.

    I checked the documentation and you are right.

    Which document should I use to get the Price from a regular table?

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

    The temporary table gets filled with data in AxdPricelist.insertPriceDiscTmpPrintout(), doesn't it?

  • MarcoPie Profile Picture
    15 on at

    Hey again Martin,

    I have very limited experience with AX structure. How can I check this?

  • dolee Profile Picture
    11,279 on at

    Hi Marco,

    Martin is right. I made a mistake earlier, sorry.

    The first row returned happens to have empty value for "Currency". I changed to another field with value (I used the Amount field) and I can see the return value.

    Also, when I test it the compiler complained about found.Amount. in the Console.WriteLine statement. I changed it to found[0].Amount instead.

    You can attach the AX server process in VS2010 and set a breakpoint at the method Martin mention. There you can check whether anything was added to the temp table.

    Regards,

    Dominic

  • MarcoPie Profile Picture
    15 on at

    If I try to use found[0].Amount I get a compile error saying:

    Cannot apply indexing with [] to an expression of type 'AXConnection.AXWebServices.AxdPricelist'

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