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, ...
Answered

Custom service issue in D365FO after upgrade from AX 2012

(0) ShareShare
ReportReport
Posted on by 50

We are getting error 500 while trying to use some of our custom services in D365FO , same services where working fine in AX 2012 , when i checked the issue i noticed that when we return a class as a return type service not working but if we return string or another type it is it working fine , you can check the below sample :

XXXX.devaos.sandbox.ax.dynamics.com/.../SMCIntegrationWorkerPaySlipDataSvcGroup

AutoDeploy is active in service group and all classes decorated with DataContractAttribute and DataMemberAttribute

If we return anytype or string in the below service it is working fine , 

[ 
AifCollectionTypeAttribute('_paySlipContract', Types::Class, classStr(SMCIntegrationWorkerPaySlipContract)),
AifCollectionTypeAttribute('return',Types::Class,classStr(SMCIntegrationWorkerPaySlipResponse)) 
]
public SMCIntegrationWorkerPaySlipResponse getPaySlip(SMCIntegrationWorkerPaySlipContract _paySlipContract)
{

SMCIntegrationWorkerPaySlipResponse response = new SMCIntegrationWorkerPaySlipResponse();

SMCHcmWorkerProduct hcmWorkerProduct;
SMCHcmWorkerEmploymentType hcmWorkerEmploymentType;
SMCHcmWorkerPaySlipExclude hcmWorkerPaySlipExclude;


SMCIntegrationWorkerPaySlipDataSvc::validate(_paySlipContract);

// Code removed 

return response;

}

Sample of return class 

[DataContractAttribute]
public class SMCIntegrationWorkerPaySlipResponse
{

str bankAccount;


[DataMemberAttribute]
public str bankAccount(str _bankAccount = bankAccount)
{
bankAccount = _bankAccount;
return bankAccount;
}

// Code removed 

}

  • Suggested answer
    Odaihoseh Profile Picture
    50 on at
    RE: Custom service issue in D365FO after upgrade from AX 2012

    I commented the below code and it is working now and tested and returned the required object using c# console application  , and your static also will work , So the conclusion here , if we method doesn't return List , no need to add  AifCollectionTypeAttribute attribute 

    also we can use it as static with  AifCollectionTypeAttribute  

    *

    [

    // AifCollectionTypeAttribute('paySlipContract',Types::Class, classStr(SMCIntegrationWorkerPaySlipContract))

    // AifCollectionTypeAttribute('return',Types::Class,classStr(SMCIntegrationWorkerPaySlipResponse))

    */

    public class SMCIntegrationWorkerPaySlipDataSvc
    
    {
    
       PayrollPayStatement                 payrollPayStatement;
    
       PayrollPayPeriod                    payrollPayPeriod;
    
       PeriodStart                         periodStart;
    
       PeriodEnd                           periodEnd;
    
       HcmWorker                           hcmWorker;
    
       HcmEmployment                       hcmEmployment;
    
       HcmWorkerBankAccount                hcmWorkerBankAccount;
    
       Amount                              totalEarnings;
    
       int                                 workingDays;
    
       Amount                              totalDeduction;
    
       /*
    
       [    
    
        //   AifCollectionTypeAttribute('paySlipContract',Types::Class, classStr(SMCIntegrationWorkerPaySlipContract))
    
          // AifCollectionTypeAttribute('return',Types::Class,classStr(SMCIntegrationWorkerPaySlipResponse))    
    
       ]
    
       */
    
       public  SMCIntegrationWorkerPaySlipResponse getPaySlip(SMCIntegrationWorkerPaySlipContract _paySlipContract)
    
       {
    
           SMCIntegrationWorkerPaySlipResponse response;
    
           SMCHcmWorkerProduct                 hcmWorkerProduct;
    
           SMCHcmWorkerEmploymentType          hcmWorkerEmploymentType;
    
           SMCHcmWorkerPaySlipExclude          hcmWorkerPaySlipExclude;
    
           SMCIntegrationWorkerPaySlipDataSvc::validate(_paySlipContract);

  • Verified answer
    Sergei Minozhenko Profile Picture
    23,083 on at
    RE: Custom service issue in D365FO after upgrade from AX 2012

    Hi Odai,

    I did a quick test and the issue was solved by using static modified for service method. Please, double-check other service methods for the same service object (if you have them)

    [
    AifCollectionTypeAttribute('_paySlipContract', Types::Class, classStr(SMCIntegrationWorkerPaySlipContract)),
    AifCollectionTypeAttribute('return',Types::Class,classStr(SMCIntegrationWorkerPaySlipResponse))
    ]
    public static SMCIntegrationWorkerPaySlipResponse getPaySlip(SMCIntegrationWorkerPaySlipContract _paySlipContract)
    {
    
    SMCIntegrationWorkerPaySlipResponse response = new SMCIntegrationWorkerPaySlipResponse();
    
    SMCHcmWorkerProduct hcmWorkerProduct;
    SMCHcmWorkerEmploymentType hcmWorkerEmploymentType;
    SMCHcmWorkerPaySlipExclude hcmWorkerPaySlipExclude;
    
    
    SMCIntegrationWorkerPaySlipDataSvc::validate(_paySlipContract);
    
    // Code removed 
    
    return response;
    
    }

  • Odaihoseh Profile Picture
    50 on at
    RE: Custom service issue in D365FO after upgrade from AX 2012

    Actually already tried it but it doesn't work with me  

  • Sergei Minozhenko Profile Picture
    23,083 on at
    RE: Custom service issue in D365FO after upgrade from AX 2012

    Hi Odai,

    It could be that you have issues with List member. Can you try to comment out them in contract class and check if service works or not?

  • Odaihoseh Profile Picture
    50 on at
    RE: Custom service issue in D365FO after upgrade from AX 2012

    No i have other members inside response and i have other members in request

    [DataContractAttribute]
    
    public class SMCIntegrationWorkerPaySlipContract
    
    {
    
       int             tMonth,tYear;
    
       str             workerKey;
    
       [DataMemberAttribute]
    
       public int Month(int _tMonth = tMonth)
    
       {
    
          tMonth =  _tMonth;
    
          return tMonth;
    
       }
    
       [DataMemberAttribute]
    
       public str WorkerKey(str _workerKey = workerKey)
    
       {
    
          workerKey =  _workerKey;
    
          return workerKey;
    
       }
    
       [DataMemberAttribute]
    
       public int Year(int _tYear = tYear)
    
       {
    
          tYear =  _tYear;
    
          return tYear;
    
       }
    
       static SMCIntegrationWorkerPaySlipContract construct()
    
       {
    
           return new SMCIntegrationWorkerPaySlipContract();
    
       }
    
    }
    
    //*********************************************************************************************************
    
    [DataContractAttribute]
    
    public class SMCIntegrationWorkerPaySlipResponse
    
    {
    
       int     tMonth,tYear;
    
       str     workerKey;
    
       int     unPaidLeaves;
    
       int     workingDays;
    
       str     bankAccount;
    
       List    earnings;
    
       List    deductions;
    
       Amount  totalEarnings;
    
       Amount  totalDeductions;
    
       Amount  netPay;
    
       [DataMemberAttribute]
    
       public str bankAccount(str _bankAccount = bankAccount)
    
       {
    
          bankAccount =  _bankAccount;
    
          return bankAccount;
    
       }
    
       [DataMemberAttribute]
    
       public int Month(int _tMonth = tMonth)
    
       {
    
          tMonth =  _tMonth;
    
          return tMonth;
    
       }
    
       [DataMemberAttribute]
    
       public Amount netPay(Amount _netPay = netPay)
    
       {
    
          netPay =  _netPay;
    
          return netPay;
    
       }
    
       [
    
           DataMemberAttribute("Deductions"),
    
           AifCollectionTypeAttribute("return", Types::Class, classStr(SMCIntegrationWorkerPaySlipDeductions))
    
       ]
    
       public List parmDeductions(List _deductions = deductions)
    
       {
    
           deductions = _deductions;
    
           return deductions;
    
       }
    
       [
    
           DataMemberAttribute("Earnings"),
    
           AifCollectionTypeAttribute("return", Types::Class, classStr(SMCIntegrationWorkerPaySlipEarnings))
    
       ]
    
       public List parmEarnings(List _earnings = earnings)
    
       {
    
           earnings = _earnings;
    
           return earnings;
    
       }
    
       [DataMemberAttribute]
    
       public Amount totalDeductions(Amount _totalDeductions = totalDeductions)
    
       {
    
          totalDeductions =  _totalDeductions;
    
          return totalDeductions;
    
       }
    
       [DataMemberAttribute]
    
       public Amount totalEarnings(Amount _totalEarnings = totalEarnings)
    
       {
    
          totalEarnings =  _totalEarnings;
    
          return totalEarnings;
    
       }
    
       [DataMemberAttribute]
    
       public int unPaidLeaves(int _unPaidLeaves = unPaidLeaves)
    
       {
    
          unPaidLeaves =  _unPaidLeaves;
    
          return unPaidLeaves;
    
       }
    
       [DataMemberAttribute]
    
       public str WorkerKey(str _workerKey = workerKey)
    
       {
    
          workerKey =  _workerKey;
    
          return workerKey;
    
       }
    
       [DataMemberAttribute]
    
       public int workingDays(int _workingDays = workingDays)
    
       {
    
          workingDays =  _workingDays;
    
          return workingDays;
    
       }
    
       [DataMemberAttribute]
    
       public int Year(int _tYear = tYear)
    
       {
    
          tYear =  _tYear;
    
          return tYear;
    
       }
    
    }

  • Sergei Minozhenko Profile Picture
    23,083 on at
    RE: Custom service issue in D365FO after upgrade from AX 2012

    Hi Odai,

    So you have only one string member in response? What about request parameter? Do you have a collection members there?

  • Odaihoseh Profile Picture
    50 on at
    RE: Custom service issue in D365FO after upgrade from AX 2012

    it return contract class (SMCIntegrationWorkerPaySlipResponse) as a response and this class is decorated by  [DataContractAttribute] and the parameters inside it decorated with [DataMemberAttribute] as the above sample .

  • Sergei Minozhenko Profile Picture
    23,083 on at
    RE: Custom service issue in D365FO after upgrade from AX 2012

    Hi Odai,

    I see List type variables in the contract, are they part of the response? If yes, what kind of values types you are storing there and have you properly decorated them in contract class?

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

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Jahanvi Profile Picture

Jahanvi 35

#2
PJ JohnPaul Profile Picture

PJ JohnPaul 5

#3
Anton Venter Profile Picture

Anton Venter 4 Moderator

Product updates

Dynamics 365 release plans