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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 23.02.2017, 07:22   #1  
Blog bot is offline
Blog bot
Участник
 
25,459 / 846 (79) +++++++
Регистрация: 28.10.2006
waldo: Manage Web Services in Extensions
Источник: https://dynamicsuser.net/nav/b/waldo...-in-extensions
==============

At this moment, I’m working on an Extension for Dynamics 365. One of the requirements is basically “publish an interface to an external packet”. In other words: “publish a bunch of web services”.

Now, I’m always trying to find the “best practice” for different circumstances. That’s also why I’m so deep into PowerShell – I think we should automate these “Best Practices” as much as possible ;-).

But in this case – handling web services for Extensions – I still haven’t found one – so it has become kind of a workaround instead of a best practice.

A WebService should be part of the codebase

As said, we are developing an extension. And part of this extension is a bunch of web services. The way to make this possible in an extension is to export the webservices to a package with the PowerShell cmdlet “Export-NAVAppTenantWebService“.

In the background, it’s going to export some data from the “Web Service” table (well .. not really that table, but that’s not important for this blogpost) to an xml file. In short: it’s going to do an export, based on data in the DEV environment.

Now .. this “data” should be part of the code. Why? Well, just assume when someone “forks” into the codebase, he probably needs to set up a new DEV environment, apply the deltas, .. and generate the Web Services .. . Because they need to exist at the moment he’s going to build and test the extension.

In a way, I always try to do this with PowerShell (as you might have figured…), because basically I build a DEV environment with PowerShell – and the scripts that are responsible for that, are part of the source code management of my Extension – so the creation of data like this is still “sourcecontrolled” (if that’s a word at all).

How can we generate these web services?

Well, we have the “New-NAVWebService” PowerShell CmdLet that comes out of the box. Unfortunately, this doesn’t give us what we want. Because what we want, is to be able to generate a “tenant”-webservice .. basically a webservice where the “App Tenants” flag is “false”, like:



The “New-NAVWebService” cmdlet doesn’t do this.. . It creates a normal webservice. And that’s not good. We would have to manually change the flags to be able to export it to the xml.. .

Is there a solution?

Well, I didn’t solve this in a way I feel comfortable with, because I just can’t think of a decent way on how to work around this. In C/AL, it is possible to create the Web Services with code like this:



Where the “WebServiceAggregate” is a variable of the Record “Web Service Aggregate” which is temporary (important!)!

So how can I create this is in PowerShell – well, I would be able to:
  • Generate a text-file of a codeunit in PowerShell
  • Import it
  • Compile
  • Run
  • Remove the codeunit
But really .. that’s not cool, right? Anyway, you can find a raw version on my github.. . I tested it .. it does work .. but it really feels like it shouldn’t ;-).

My Workaround

So my actual (current) workaround is a simple one. Publish the web services (based on a certain prefix), and open the web service page. Then you should manually de-select the “All Tenants” checkmark for all concerning web services.

I made this into a PowerShell script that I include in every single Extension:

https://github.com/waldo1001/Cloud.R...ebServices.ps1

Conclusion

In my opinion, this is a part where Microsoft shoud come in and foresee a “New-NAVTenantWebService” CmdLet or whatever.. . Should be easy.

If anyone has a better solution – please share :-).




Источник: https://dynamicsuser.net/nav/b/waldo...-in-extensions
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
waldo: Microsoft Dynamics NAV 2017 – what’s really new? Blog bot NAV: Blogs 0 13.10.2016 05:22
NAV Team: Using Web Services to Manage the Dynamics NAV Management Portal Programmatically Blog bot Dynamics CRM: Blogs 0 13.01.2016 12:00
Freddys: Web Services changes in NAV 2009 SP1 Blog bot Dynamics CRM: Blogs 0 27.05.2009 23:52
Freddys: Web Services changes in NAV 2009 SP1 Blog bot Dynamics CRM: Blogs 0 27.05.2009 20:52
Inside Dynamics AX 4.0: The Web Framework Blog bot DAX Blogs 0 25.10.2007 03:04
Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

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

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

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 15:20.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.