Tuesday, 18 May 2021

AX 2012 X++ Consume aif web service by passing list of objects

 1- Create data contract class as below

[DataContractAttribute]

class HP_TestContract

{

    str Id;

    str Name;


[DataMemberAttribute('Id'), SysOperationDisplayOrderAttribute('1')]

public str ParamId(str _Id = Id)

{

    Id = _Id;

    return Id;

}

[DataMemberAttribute('Name'), SysOperationDisplayOrderAttribute('2')]

public str ParamName(str _Name = Name)

{

    Name = _Name;

    return Name;

}

}

2-Add an AIF service method

[SysEntryPointAttribute(true),
DataMemberAttribute("HP_TestContract"),
AifCollectionTypeAttribute("_contactList",Types::Class, classStr(HP_TestContract)),
AifCollectionTypeAttribute("return",Types::Class, classStr(HP_TestContract))]
public List HeshamList(List _contactList)
{
//_contactList = contactList;
return _contactList;
}

No comments:

Post a Comment