Test custom services using raw HTTP

You will need client id and client secret.
Client should be registered in AX at System administration -> Setup -> Azure Active Directory applications
All requests was tested using Fiddler and it's Composer->Scratchpad feature.
You can find implementation of calc service following this link.
There are couple of examples how you can test your services:

API (JSON)

Make sure that empty line which dividing HTTP headers and body is empty, without space. Otherwise you will most probably get an error.

Request to get auth token:
POST https://login.windows.net/{domain}/oauth2/token HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Host: login.windows.net

resource=https://{aos}.cloudax.dynamics.com&client_id={ClientId}&client_secret={ClientSecret}&grant_type=client_credentials
Request to service:
POST https://{aos}.cloudax.dynamics.com/api/Services/VKOServiceGroup/VKOCalcService/calc HTTP/1.1
Content-Type: application/json
Accept: application/json
Accept-Charset: UTF-8
Authorization: Bearer {AuthToken}
Host: {aos}.cloudax.dynamics.com

{
"_calcContract":
    {
         "arg1": 2,
         "arg2": 2,
         "operation": 0,
         "list": [{
             "a": 0,
         },
         {
             "a": 1,
         }],
         "subCalc": {
             "a": 5
         }
    }
}

SOAP


SoapUI can form a correct request for you using wsdl https://{aos}.cloudax.dynamics.com/soap/Services/VKOServiceGroup?wsdl
You can use SoapUI to send request, you just need to manually add Authorization header with value Bearer {AuthToken}

Example of SOAP request:
POST https://{aos}.cloudax.dynamics.com/soap/services/VKOServiceGroup HTTP/1.1
Content-Type: text/xml
SOAPAction: http://tempuri.org/Calc/calc
Authorization: Bearer {AuthToken}
Host: {aos}.cloudax.dynamics.com

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:dat="http://schemas.microsoft.com/dynamics/2013/01/datacontracts" xmlns:tem="http://tempuri.org" xmlns:dyn="http://schemas.datacontract.org/2004/07/Dynamics.AX.Application">
   <soapenv:Header>
   </soapenv:Header>
   <soapenv:Body>
      <tem:calc>
         <tem:_calcContract>
            <dyn:List>
               <dyn:SubCalc>
                  <dyn:a>1</dyn:a>
               </dyn:SubCalc>
            </dyn:List>
            <dyn:arg1>2</dyn:arg1>
            <dyn:arg2>2</dyn:arg2>
            <dyn:operation>0</dyn:operation>
            <dyn:subCalc>
               <dyn:a>1</dyn:a>
            </dyn:subCalc>
         </tem:_calcContract>
      </tem:calc>
   </soapenv:Body>
</soapenv:Envelope>
SOAPAction: http://tempuri.org/{External Name property from service}/calc

C#

http://www.k3technical.com/consume-ax7-custom-web-service-by-soap-endpoint/
http://dev.goshoom.net/en/2017/02/json-based-custom-service-with-parameters/

Search

About

DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics AX.

Authors are allowed to set their own AdSense units.
Join us.

Blog Tags