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 can I arrange Custom service XML schema elements?

(0) ShareShare
ReportReport
Posted on by 364

Hi All, 

I have developed a custom service in AX 2012, in which the expected XML response schema should be as shown below.

<?xml version="1.0"?>

<LoginResponse>

    <CustId>1234ab5678</CustId>

    <EmailId>abc.xyz@gmail.com</EmailId>

    <Authentication>

        <ResponseCode>900</ResponseCode>

        <ReasonCode>901</ReasonCode>

        <ReasonDescription>Invalid Email Address</ReasonDescription>

    </Authentication>

  </LoginResponse>

 

However, the schema generated through the custom service is build with a slight differences where the order of the xml elements [CustID, EmailID, Authentication, ResponseCode, ReasonCode, Description] and the root element label name “WebServiceValidateLoginResponse  xmlns='http://tempuri.org'”  are incorrect when compared with the expected xml.

Generated Schema:

 

<?xml version="1.0"?>

<WebServiceValidateLoginResponse  xmlns='http://tempuri.org'>    

    <Authentication>        

        <ReasonCode>901</ReasonCode>

        <ReasonDescription>Invalid Email Address</ReasonDescription>

        <ResponseCode>900</ResponseCode>

    </Authentication>

    <CustId>1234ab5678</CustId>

    <EmailId>abc.xyz@gmail.com</EmailId>    

  </WebServiceValidateLoginResponse>

 


I Observe that, the elements in the generated schema are arranged in the alphabetic order.

 

To change the tag name, I have tried by changing the label for DataContract class in the [DataContractAttribute] and the same is updated in the Service reference, but in the xml schema it is not getting updated accordingly. And to get the xml elements in sequence as per the requirement I have tried changing the sequence of the parm methods using SysOperationDisplayOrderAttribute("1") in the data contract class and also changed the sequence in the service reference but still I am facing challenges in generating the xml schema.

 

Request you to help me out by sharing your ideas on the same. 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

    SysOperationDisplayOrderAttribute is used for dialogs in GUI, not for the files generated through the AIF file system adapter. I don't think you'll be able to change the order; you should rather change your expectation.

    Note that the order of elements normally doesn't matter. The code consuming the response can extract data from Authentication/ResponseCode (for example) without any knowledge if it's the first or the last element there.

  • Venkatdax0 Profile Picture
    364 on at

    Hi Martin,

    Thank you for clarifying my query. Can you please let me know how can i change the root tag name i.e.. <WebServiceValidateLoginResponse  xmlns='http://tempuri.org'>.

     

    I have tried by changing the label for the data contract class and i observe that, the label is updated in the Service reference but the same is not generated in the xml schema.

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

    Can you please show us the data contract class returned from your service operation?

  • Venkatdax0 Profile Picture
    364 on at

    DataContract class:

     


    [DataContractAttribut("Login")]

    class LoginContract

    {

    str         CustID, EmailId;

    AuthenticationContract         authenticationContract;

    }

    [DataMemberAttribute("Authentication")]

    public AuthenticationContract parmAuthenticationContract(AuthenticationContract  _authenticationContract  = authenticationContract  )

    {

    authenticationContract  = _authenticationContract  ;

    return authenticationContract  ;

    }

    [DataMemberAttribute("CustId")]

    public str parmCustID(str _CustID = CustID)

    {

    CustID = _CustID;

    return CustID;

    }

    [DataMemberAttribute("EmailID")]

    public str parmEmailID(str _EmailID = EmailID)

    {

    EmailID= _EmailID;

    return EmailID;

    }

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

    Ah, maybe it's actually taken from the service operation name. Isn't your operation called WebServiceValidateLogin?

    Unfortunately I don't have any AX 2012 environment running at the moment, so I can't take a look at how it works.

  • Venkatdax0 Profile Picture
    364 on at

    WebService is my Service class and ValidateLogin is the service operation. I believe, we have to label the ValidateLogin as 'Login' at the AX level but not sure where to do it.

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

    It seem seems then that the name is generated from the service name and the operation name, suffixed with "Response". It doesn't look like you can change the format.

    Either accept what AX gives you or transform it to another format (see About the AIF Pipeline and Transforms).

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