AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 22.07.2017, 14:17   #1  
Blog bot is offline
Blog bot
Участник
 
25,643 / 848 (80) +++++++
Регистрация: 28.10.2006
goshoom: Discovery of JSON-based custom services in AX 7
Источник: http://dev.goshoom.net/en/2017/07/di...vices-in-ax-7/
==============

If you download AX integration samples from GitHub, you’ll see (in JsonConsoleApplication project) that you can call JSON-based custom services by code like this:

var request = HttpWebRequest.Create(ClientConfiguration.Default.UriString + "api/services/UserSessionService/AifUserSessionService/GetUserSessionInfo");request.Headers[OAuthHelper.OAuthHeader] = OAuthHelper.GetAuthenticationHeader();request.Method = "POST";request.GetResponse();






It will call the operation and return its return value as JSON:

{ "$id":"1", "AOSLocaleName":"en-US", "AXLanguage":"EN-US", "Company":"DAT", "CompanyTimeZone":58, "CurrencyInfo": { "$id":"2", "CurrencyCode":"USD", "Description":"US Dollar", "ExchangeRate":100.0, "ISOCurrencyCode":"USD", "Prefix":"","Suffix":"" }, "IsSysAdmin":true, "UserId":"wintermute", "UserPreferredCalendar":0, "UserPreferredTimeZone":18}






This is what happens when you use the POST method of HTTP; if you switch to GET, you’ll actually get some information about the service.

Therefore if you merely change the value of request.Method:

var request = HttpWebRequest.Create(ClientConfiguration.Default.UriString + "api/services/UserSessionService/AifUserSessionService/GetUserSessionInfo");request.Headers[OAuthHelper.OAuthHeader] = OAuthHelper.GetAuthenticationHeader();request.Method = "GET";request.GetResponse();you’ll get a very different response:

{ "Parameters":[], "Return": { "Name":"return", "Type":"AifUserSessionInfo" }}






You can see that the operation doesn’t expect any parameters and it returns a single object of AifUserSessionInfo type. This gives you some limited information about how to use this service.

You can also use GET requests to discover existing services and their operations.

/api/services gives you a list of all service groups:

{"ServiceGroups":[{"Name":"AxClient"},…,{"Name":"UserSessionService"}…]}






/api/services/UserSessionService provides a list of services in the service group:

{"Services":[{"Name":"AifUserSessionService"}]}






/api/services/UserSessionService/AifUserSessionService shows all operations of the individual service:

{ "Operations": [ {"Name":"ApplyTimeZone"}, {"Name":"GetAccessRights"}, {"Name":"GetPartitionKey"}, {"Name":"GetPartitionKeysForUser"}, {"Name":"GetUserSessionInfo"}, {"Name":"IsSinglePartitionSystem"}, {"Name":"RemoveTimeZone"} ]}






Don’t forget than opening an URL in browser makes a GET request, therefore you don’t have to write any code to get this kind of information about custom services.

But maybe you would like something a bit more sophisticated, which is the topic of the next post: Open API for JSON-based custom services in AX 7.



Источник: http://dev.goshoom.net/en/2017/07/di...vices-in-ax-7/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
emeadaxsupport: AX Performance Troubleshooting Checklist Part 1B [Application and AOS Configuration] Blog bot DAX Blogs 0 05.09.2014 21:11
daxdilip: AIF Tip - Troubleshooting custom Dynamics AX 2012 AIF Services Blog bot DAX Blogs 0 19.09.2013 05:16
emeadaxsupport: AX for Retail 2012 R2: Adding a Custom User Control to the POS Blog bot DAX Blogs 0 27.02.2013 07:14
dynamics-ax: Microsoft Dynamics AX 2012 and the use of Claims Based Security Blog bot DAX Blogs 0 08.03.2011 06:24
gatesasbait: Dynamics AX 2009 SSRS and SSAS Integration Tips Blog bot DAX Blogs 3 09.07.2009 13:07

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 01:37.