JSON-based custom service with parameters (AX 7)

Dynamics 365 for Operations deploys custom web services in two ways: as SOAP-based services and JSON-based services. AX developers are often familiar with SOAP services (which were used in AX 2012), but JSON-based ones are new to them. One particular challenge is passing arguments to a service. Let’s say we have an Add operation, which …

Continue reading ‘JSON-based custom service with parameters (AX 7)’ »

Data contract serialization from X++

You can decorate classes in AX2012 with DataContractAttribute in much the same way as in .NET with System.Runtime.Serialization.DataContractAttribute. The same is true also for DataMemberAttribute. This is a simple data contract class in X++: [DataContractAttribute] class ItemContract { str name;   [DataMemberAttribute("Name")] public str parmName(str _name = name) { name = _name; return name; } …

Continue reading ‘Data contract serialization from X++’ »

ReceivedFault is not marked as serializable

Last week I needed to use a third-party web service in AX2009. I created a service reference in AOT, so AX generated necessary code and configuration and I was immediately able to get data from the service. Quickly done, almost without any work. Great. But I wouldn’t write about it if that was all. The …

Continue reading ‘ReceivedFault is not marked as serializable’ »

Serialization of enum types

Situation: A web service hosted on Dynamics AX 2012 AOS; it finds some data in database on demand and returns them. The type of one of the fields is UtilElementType enum. Problem: If no record is found, system throws the exception “Enum value ‘0’ is invalid for type ‘Dynamics.Ax.Application.UtilElementType’ and cannot be serialized.” Analysis: Fortunately, …

Continue reading ‘Serialization of enum types’ »