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)

How to serialize object to XML ??

(0) ShareShare
ReportReport
Posted on by

Hello,

It's look like a very easy question... but i can't find correct answer...

What is the easiest way to serialize object to XML ??

Thank you in advance!!

*This post is locked for comments

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

    Can you give us more information, please? There are quite a few ways, depending on what you're doing.

  • Community Member Profile Picture
    on at

    I declare class with several fields ... create an instance of class ...

    E.G.

    class Test {

    str a;

    int b;

    }

    I have to send to another system information about this object ... Doesnt matter how ... XML / JSON ...

    As output and want to have a string That describes the object E.G. "<Classname =" test "itemid =" 12341234 "a =" bla bla "b = 102032>

    and need to have solution wher as input and pass the instance and as output and get pages with XML / JSON ...

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

    I know what serialization is, but I don't know your context.

    For example, you can create the class in .NET, fill it from X++ via .NET Interop and then use the usual XML and JSON serializers in .NET. I can think of quite a few other approaches, but I can't say which one would be suitable for you needs.

  • Community Member Profile Picture
    on at

    Ok :) it's connected with events topic...

    I have two systems e.g.(AX and CRM)...

    And i want to make synchronization between the systems based on events...

    I need in CRM only a few specyfic information...

    So when something which is neede in CRM is INSTER/UPDATE/DELETE in AX i want to send that information to CRM...

    I have class that handle event and i need te prepare information which will be send to DATA BUS.

    I created classes for each entity which i want to synchronize e.g. (AXtoCRMproduct) and that class contains all fields which i want to send to CRM... When i handle event i create instance of class AXtoCRMproduct and fill all fields... Next i want to input that instance and get string witch XML/JSON which will be send to DATA BUS.

    I created classes for entities because i want to have one single place which generate message... method which gets OBJECT and return string.

  • Verified answer
    Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    Then I would say that my suggested solution makes a good sense. Create AXtoCRMproduct in .NET (if you're not aware of it, you can add VS projects to AOT and AX can deploy them automatically, which makes things very convenient) and handle both serialization and communication in a .NET class library.

    You mentioned C# in another thread - if you're more with C# than with AX, it has an extra advantage for you.

  • Community Member Profile Picture
    on at

    :) i could do it that way... if my boss accept that solution...

    But now i have to do this fully in X++... The company which will be manage this solution in the future have only X++ developers and whole project must be done in X++...

    I see the advantages :) but in my opinion in that case it wouldn't be possible...

    I have to make XML/JSON in AX using X++ and generate string for that purpose...

    I started witch xmlDocument and xmlElement and wanted to create my own parser... but it's look like wrong approach :)

    I'm looking for something like Common.xml() but for objects :)

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

    If the whole project must be in X++, how do they build reports, consume external web services, develop Enterprise Portal and so on? Such a requirement makes nov sense; it just says that they're not qualified to work on AX. They'll have a really hard time in AX 7...

    Well, you can suggest developing XML and JSON serializer in X++, if they prefer spending days rather doing that to writing ten lines of code in C#. Using XmlDocument is possible, but resource-consuming and it won't help you with JSON.

    If you use a search engine, you can find my blog post about using data contract serializer for X++ data contracts, but it personally wouldn't use in your case. Trust me that if I was able to develop it, I probably have some reasons for my recommendation against it.

  • Community Member Profile Picture
    on at

    Hehe you are used to work for hudge companies... which fully use functionality of AX.... :)

    My project is for company which abandoned excel and change it to AX :) They didnt even heard about reports, EP :) I have to build solution based on X++ :)

    I thought thaht there is built.in function for serialize objects... Similar to build-in xml() from Common class...

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

    That's the first time in my life when I hear about a client not using reports. I have no idea how they use the system.\

    I wonder why they're willing to pay for enterprise-scale ERP system if they don't need it. Will they be able to maintain it at all? For example, they need a SQL Server administrator.

    Anyway, I gave some several suggestions, now it's up to you what you choose to do. In my opinion, anything that doesn't utilize existing serializers is a waste of resources, but maybe they're rich...

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