Microsoft Dynamics AX 2012 Class Libraries (DLLs)
Purpose: The purpose of this document is to illustrate how to work with class libraries in the context of Microsoft Dynamics AX 2012.
Challenge: For the purposes of POC, integration project or development project you may need to consume Microsoft Dynamics AX 2012 Web Services from external class libraries or call external Web Services from Microsoft Dynamics AX 2012 managed code assemblies.
Solution: In this walkthrough I'm going to highlight number of ways you can consume Microsoft Dynamics AX 2012 Web Services from external class library using configuration settings in application config file or handled in the application code. Also I will highlight how develop Microsoft Dynamics AX 2012 managed code assemblies and then call external Web Services from there.
Walkthrough
Calling Microsoft Dynamics AX 2012 Web Service from external Class Library (DLL)
First of all I will expose Microsoft Dynamics AX 2012 Web Services via Inbound ports using NET.TCP and HTTP adapters
Inbound port (NET.TCP)
Inbound port (HTTP)
IIS
After Web Services have been exposed through Inbound ports in your client application you can Add Service Reference using WSDL URI as shown below
Add Service Reference (NET.TCP)
Add Service Reference (HTTP)
Added Service Reference will show up in your project as below
Solution Explorer (Console App)
Please note that corresponding Endpoint and Binding details will be added to App.config after you added Service Reference
App.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_AdvancedLedgerEntryService" />
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://ax2012r2a:8201/DynamicsAx/Services/AlexServices"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_AdvancedLedgerEntryService"
contract="ServiceReference1.AdvancedLedgerEntryService" name="NetTcpBinding_AdvancedLedgerEntryService">
<identity>
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
|
Now I’ll create a class library project and Add Service Reference too
Solution Explorer (Class Library)
Similarly to above corresponding Endpoint and Binding details will be added to App.config
App.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_AdvancedLedgerEntryService" />
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://ax2012r2a:8201/DynamicsAx/Services/AlexServices"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_AdvancedLedgerEntryService"
contract="ServiceReference1.AdvancedLedgerEntryService" name="NetTcpBinding_AdvancedLedgerEntryService">
<identity>
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
|
In fact when leveraging business logic from class library you have to use client application config file instead of original DLL config file. That’s why I will copy Endpoint and Binding details from DLL config file over to client app config file
Client application Config file
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_AlexService" />
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://ax2012r2a:8201/DynamicsAx/Services/AlexServices"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_AlexService"
contract="AXServiceReference.AlexService" name="NetTcpBinding_AlexService">
<identity>
<userPrincipalName value="admin@Contoso.com" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
|
Now my client application will be well aware about Endpoint and Binding details for Microsoft Dynamics AX 2012 Web Service
Alternatively you can handle Endpoint and Binding details for Microsoft Dynamics AX 2012 Web Service directly in client application code as shown below
Client application Code
BasicHttpBinding binding = new BasicHttpBinding();
binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
EndpointAddress address = new EndpointAddress("http://ax2012r2a.contoso.com/MicrosoftDynamicsAXAif60/AlexWebServices/xppservice.svc");
AlexServiceClient client = new AlexServiceClient(binding, address);
CallContext context = new CallContext();
context.Company = "usmf";
client.ClientCredentials.Windows.ClientCredential.Domain = "contoso";
client.ClientCredentials.Windows.ClientCredential.UserName = "Admin";
client.ClientCredentials.Windows.ClientCredential.Password = "pass@word1";
try
{
client.method1(context);
}
catch (Exception e)
{
}
|
Call external Web Service from Microsoft Dynamics AX 2012 Class Library (DLL)
In the second part of the walkthrough I’m going to wrap a business logic calling external Web Service with Microsoft Dynamics AX 2012 managed code assembly
First off I’ll create Class Library project with minimalistic implementation for a single class and method which mimic calling external Web Service
Class Library
As coding is complete I’ll add Class Library project directly into Microsoft Dynamics AX 2012 AOT. Please note that I have Microsoft Dynamics AX 2012 Visual Studio Tools installed to accomplish this: https://technet.microsoft.com/en-us/library/dd309576.aspx
My project now will change its icon to Microsoft Dynamics specific one, after that I’ll be able to select auto-deployment options in Project Properties. Specifically I will choose to deploy assembly to Microsoft Dynamics AX 2012 Client (Yes) and Server (Yes)
Class Library (Deployment)
After successful deployment my project will show up in Microsoft Dynamics AX 2012 AOT
AOT – C Sharp Projects
Here’s the implementation of class and method which mimic calling external Web Service from within Microsoft Dynamics AX 2012 managed code assembly
Source code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AlexDLL
{
public class Class1
{
public string method1()
{
return "External Web Service call";
}
}
}
|
Generally it would be a good idea to encapsulate business logic calling external Web Service in a single method in managed code assembly, this way you can simply call a single method in X++ to consume Web Service and obtain the result
When deploying assemblies from within Visual Studio you may need to make sure that “Enable the hot-swapping of assemblies for each development session” setting is selected in Microsoft Dynamics AX 2012 Server Configuration Utility in order to avoid deployment errors
Microsoft Dynamics AX 2012 Server Configuration Utility
Before you deploy you will need to Sign the assembly in Project Properties > Signing
Create Strong Name Key
Now we are ready to deploy the assembly
Deploy
Upon successful deployment you will be able to use IntelliSense in X++ and consume elements of managed code assembly namespace just the way you consume native X++ business logic classes
X++ code
static void DLL(Args _args)
{
AlexDLL.Class1 class1 = new AlexDLL.Class1();
info(class1.method1());
}
|
The result will look like below
Result
Please learn more about Deploying Managed Code Assemblies here: https://msdn.microsoft.com/en-us/library/gg889192.aspx
Summary: In this walkthrough I illustrated how to call Microsoft Dynamics AX 2012 SOAP Web Services from Windows 8 application using JavaScript and shed some light into what's happening behind the scenes when you call Web Service, how request and response look like and what you have to do to successfully call Microsoft Dynamics AX 2012 SOAP-based Web Services.
Tags: Microsoft Dynamics AX 2012, Custom Web Services, X++, C#.NET, HTTP, NET.TCP, Config file, Class library, DLL, Endpoint, Binding.
Note: This document is intended for information purposes only, presented as it is with no warranties from the author. This document may be updated with more content to better outline the issues and describe the solutions.
Author: Alex Anikiev, PhD, MCP
Great post! I am actually getting ready to across this information, It's very helpful for this blog.Also great with all of the valuable information you have Keep up the good work you are doing well.
ReplyDeleteJ2ee training in chennai
Dear Alex,
ReplyDeleteWe are trying to integrate 2 separate AX implementations using AIF.
Steps:
1. Create AIF service in AX environment 1.
2. Wrote a .NET wrapper around the AIF, using a class library project type and added the service reference.
3. Deployed class library project in AOT of AX environment 2 and also added classlibrary.dll and classlibrary.dll.config in the Bin folder of 2nd environment and than added reference to dll in the AOT.
4. We finally wrote X++ job to call(consume) the class library that was added in the AOT.
Exception :
System.InvalidOperationException: Could not find default endpoint element that references contract 'AMSSVCSR.HREMPAIFService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
Great post going through your articles..this is really helping.
ReplyDeleteQTP Training in Chennai
Hi there, You have done an incredible job. I’ll definitely digg it and personally recommend to my friends. I’m sure they’ll be benefited from this site..Keep update more excellent posts..
ReplyDeleteBack to original
ReplyDeleteTruely a very good article on how to handle the future technology. After reading your post,thanks for taking the time to discuss this content.
Digital Marketing Company in Chennai
This blog is very well done, thus it is very well useful too, so i am expecting more things from your blog.
ReplyDeleteDigital Marketing Company in Chennai
I was researching on the best methods of How to Compose a College Research Paper before I landed on this page and I have found an interesting blog with great article and design that is worth commenting on. I am looking forward to reading more interesting and intriguing articles from this site and I hope the writer will continually keep us updated with new articles.
ReplyDeleteReally Good article.provided a helpful information about Microsoft dynamics AX 2012 class libraries.keep updating...
ReplyDeleteE-mail marketing company in india
It is nice blog Thank you porovide importent information and i am searching for same information to save my TimeMicrostrategy Online course Hyderabad
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThis is such a great resource that you are providing and you give it away for free. I love seeing websites that understand the value of providing a quality resource for free. It is the old what goes around comes around routine.
ReplyDeletehotmail.com iniciar sesion
It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
ReplyDeleteClick here:
angularjs training in chennai
Click here:
angularjs2 training in chennai
Click here:
angularjs4 Training in Chennai
Click here:
angularjs5 Training in Chennai
Click here:
angularjs training in tambaram
Hello! This is my first visit to your blog! We are a team of volunteers and starting a new initiative in a community in the same niche. Your blog provided us useful information to work on. You have done an outstanding job.
ReplyDeleteAWS Online Training | Online AWS Certification Course - Gangboard
AWS Training in Chennai | AWS Training Institute in Chennai Velachery, Tambaram, OMR
Have you been thinking about the power sources and the tiles whom use blocks I wanted to thank you for this great read!! I definitely enjoyed every little bit of it and I have you bookmarked to check out the new stuff you post
ReplyDeleteangularjs Training in chennai
angularjs Training in chennai
angularjs-Training in tambaram
angularjs-Training in sholinganallur
angularjs-Training in velachery
Nice tips. Very innovative... Your post shows all your effort and great experience towards your work Your Information is Great if mastered very well.
ReplyDeleteData Science course in rajaji nagar | Data Science with Python course in chenni
Data Science course in electronic city | Data Science course in USA
Data science course in pune | Data science course in kalyan nagar
This is good site and nice point of view.I learnt lots of useful information.
ReplyDeletepython training in tambaram | python training in annanagar | python training in jayanagar
Wow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. it is really explainable very well and i got more information from your blog.
ReplyDeleteJava training in Annanagar | Java training in Chennai
Java training in Chennai | Java training in Electronic city
Awesome! Education is the extreme motivation that open the new doors of data and material. So we always need to study around the things and the new part of educations with that we are not mindful.
ReplyDeleteangularjs Training in marathahalli
angularjs interview questions and answers
angularjs Training in bangalore
angularjs Training in bangalore
angularjs Training in chennai
Really very nice blog information for this one and more technical skills are improve,i like that kind of post.
ReplyDeleteadvanced excel training in bangalore
Nice post. Thanks for sharing the valuable information. it’s really helpful. Who want to learn this blog most helpful. Keep sharing on updated posts…
ReplyDeleteData Science Training in Indira nagar
Data Science training in marathahalli
Data Science Interview questions and answers
Data Science training in btm layout | Data Science Training in Bangalore
Data Science Training in BTM Layout | Data Science training in Bangalore
Data science training in kalyan nagar
Very nice post here thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's.
ReplyDeleteMachine learning training in chennai
machine learning course fees in chennai
top institutes for machine learning in chennai
Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic.
ReplyDeleteinformatica mdm online training
apache spark online training
angularjs online training
devops online training
aws online training
ReplyDeleteI enjoyed over read your blog post. Your blog have nice information, I got good ideas from this amazing blog. I am always searching like this type blog post. I hope I will see again.
Deer Hunting Tips Camping Trips Guide DEER HUNTING TIPS travel touring tips
Сізде тамаша мақала бар. Жақсы жаңа күн тілеймін
ReplyDeleteThông tin mới nhất về cửa lưới chống muỗi
Siêu thị cửa chống muỗi
Hé mở thông tin cửa lưới chống muỗi xếp
Phòng chống muỗi cho biệt thư ở miền Nam
https://forums.pokemmo.eu/index.php?/profile/131787-cualuoihm/
Deletehttps://doremir.com/forums/profile/cualuoihm
https://www.wincert.net/forum/profile/100889-cualuoihm/
https://www.goodreads.com/user/show/104133368-cualuoihm
kaka
Deletethanh lý phòng net
màn hình máy tính 24 inch cũ
lắp đặt phòng net
giá card màn hình
Are you looking for a business loan, personal loans, mortgage loans, car loans, student loans, unsecured consolidation loans,project funding etc ... Or simply refuse loan from a bank or financial institution for one or more reasons? We are the right solutions for credit! We offer loans to businesses and individuals with low and affordable interest rate of 2%. So if you are Interested in an urgent and secured loan. For more information kindly email us today Via: elegantloanfirm@hotmail.com.
ReplyDeleteok bạn Thực đơn giảm cân tốt và hiệu quả
ReplyDeleteMua lều xông hơi hồng ngoại tại Phú Thọ
Giảm cân nhanh trong 1 tuần
Xông mặt trị mụn đúng cách
Lều xông hơi loại nào tốt để giảm cân
Bài viết của bạn làm tôi rất thích
ReplyDeletecáo tuyết
cáo tuyết thái lan
Mua cáo tuyết
Bán cáo tuyết
bull pháp hà nội
This comment has been removed by the author.
ReplyDeleteBạn có quá hay
ReplyDeletemáy tạo hương thơm trong phòng
máy xông tinh dầu bằng điện tphcm
máy xông hương
may xong huong tinh dau
máy đốt tinh dầu điện
Hay mà thú vị
ReplyDeletecase máy tính cũ
vga cũ hà nội
mua bán máy tính cũ hà nội
Lắp đặt phòng net trọn gói
Thanks dear. Very useful. Appreciated.
ReplyDeleteI truly love this post..
ReplyDeleteThanks for sharing with us,
We are again come on your website,
Thanks and good day,
Please visit our site,
buylogo
I now own a business of my own with the help of Elegantloanfirm with a loan of $900,000.00 USD. at 2% rate charges, at first i taught with was all a joke until my loan request was process under five working days and my requested funds was transfer to me. am now a proud owner of a large business with 15 staffs working under me. All thanks to the loan officer Russ Harry he is a God sent, you can contact them to improve your business on.. email-- Elegantloanfirm@hotmail.com.
ReplyDeleteazure online training Thanks for sharing such a great information..Its really nice and informative..
ReplyDeleteThanks for sharing such a great information..Its really nice and informative.. azure online training
ReplyDeleteI think this is a really good article.Thank you so much for sharing.It will help everyone.Keep Post.
ReplyDeleteData Science Training in Hyderabad
Effective blog with a lot of information. I just Shared you the link below for Courses .They really provide good level of training and Placement,I just Had Microsoft Dynamics Classes in this institute,Just Check This Link You can get it more information about the Microsoft Dynamics course.
ReplyDeleteJava training in chennai | Java training in annanagar | Java training in omr | Java training in porur | Java training in tambaram | Java training in velachery
Awesome Blog. Really the post is very interesting.
ReplyDeleteData Science Training Course In Chennai | Data Science Training Course In Anna Nagar | Data Science Training Course In OMR | Data Science Training Course In Porur | Data Science Training Course In Tambaram | Data Science Training Course In Velachery
thus it is very well useful too, so i am expecting more things from your blog. thank your sir.
ReplyDeletePython Training in Chennai | Certification | Online Training Course | Python Training in Bangalore | Certification | Online Training Course | Python Training in Hyderabad | Certification | Online Training Course | Python Training in Coimbatore | Certification | Online Training Course | Python Training in Online | Python Certification Training Course
I would like to know more information about the new model bike. Anyway thanks a lot for sharing this post. Those guidelines additionally worked to become a good way to recognize that other people online have the identical fervour like mine to grasp great deal more around this condition. Data Science Training In Chennai | Certification | Data Science Courses in Chennai | Data Science Training In Bangalore | Certification | Data Science Courses in Bangalore | Data Science Training In Hyderabad | Certification | Data Science Courses in hyderabad | Data Science Training In Coimbatore | Certification | Data Science Courses in Coimbatore | Data Science Training | Certification | Data Science Online Training Course
ReplyDeletethis is amazing posting.. very nice write articles
ReplyDeleteBuy property online india
This library is awesome, thank you very much for sharing? From now on, I can go to the library to find more useful materials for my life and study: Khóa học bán hàng online, Khóa học facebook marketing, Khóa học quảng cáo google, Khóa học Seo Website, Học marketing, Học marketing online, Khóa học marketing online, Khóa học marketing, khóa học digital marketing, Học marketing ở đâu, Học digital marketing, Marketing facebook, Marketing căn bản, Học seo, facebook ads, facebook web, seo web, marketing là làm gì,.................
ReplyDeleteGood Post! Thank you so much for sharing this pretty post of Digital marketing, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
ReplyDeletepython Training in chennai
python Course in chennai
Title:
ReplyDeleteBig Data Hadoop Training in Chennai | Infycle Technologies
Description:
Did you want to set your career towards Big Data? Then Infycle is with you to make this into reality. Infycle Technologies gives the combined and best Big Data Hadoop Training in Chennai, in 100% hands-on training guided by specialized trainers in the field. In addition to this, the mock interviews will be given to the candidates, so that they can face the interviews with complete confidence. Apart from all, the candidates will be placed in the top MNC's with a great salary package. To get it all, call 7502633633 and make this happen for your happy life.
Best training in Chennai
Link:
ReplyDeletehttps://infycletechnologies.com/java-training-in-chennai/
Keywords:
If Java Development is a field that you're dreaming of, then we, Infycle, are with you to make your dream into reality. Infycle Technologies offers the best Java Training in Chennai, with various highly demanded software courses such as Big Data, AWS, Python, Hadoop, AWS, etc., in 100% practical training with specialized tutors in the field. Along with that, the pre-interviews will be given for the candidates to face the interviews with complete knowledge. To know more, dial 7502633633 for more.
best training institute in chennai
HELLO GET OUT OF FINANCIAL MESS WITH THE HELP OF drbenjaminfinance@gmail.com
ReplyDeleteI have been in financial mess for the past months, I’m a single mum with kids to look after. My name is REBECCA MICHAELSON, and am from Ridley Park, Pennsylvania. A couple of weeks ago My friend visited me and along our discussion she told me about DR BENJAMIN OWEN FINANCE of (drbenjaminfinance@gmail.com); that he can help me out of my financial situation, I never believed cause I have spend so much money on different loan lenders who did nothing other than running away with my money. She advised, I gave it a try because she and some of her colleagues were rescued too by this Godsent lender with loans to revive their dying businesses and paying off bills. so I mailed him and explain all about my financial situation and therefore took me through the loan process which was very brief and easy. After that my loan application worth $278,000.00USD was granted, all i did was to follow the processing and be cooperative and today I am a proud business owner sharing the testimony of God-sent Lender. You can as well reach him through the Company WhatsApp +19292227023 Email drbenjaminfinance@gmail.com
THANK YOU VERY MUCH
Very Informative blog thank you for sharing. Keep sharing.
ReplyDeleteBest software training institute in Chennai. Make your career development the best by learning software courses.
blue prism course in chennai
rpa training in chennai
best msbi training institute in chennai
This is one of the brilliant article, spent plenty of time reading and understanding it. Thanks for posting this useful information.
ReplyDeleteWeb Application Development
This is a smart blog. I mean it. You have so much knowledge about this issue, and so much passion. You also know how to make people rally behind it, obviously from the responses.
ReplyDeletedata analytics training in hyderabad
wow really good informision got lot to learn. looking forward for more informative posts from you.
ReplyDeleteFrench Online Course | French Language Course | Online French Courses
Herbal Supplement for Health and Skin Diseas to help improve the appearanceHome Remedies for Granuloma Annulare, grape seed extract is one of my favorite ingredients. In medical science, grape seed extractNatural Remedies for Granuloma Annulare is Vitamin E oil.— Herbal Supplement for Granuloma Annulare which may help explainHerbal Remedies for Granuloma Annulare for soothing your skin and reducing inflammation.
ReplyDeleteOne of several ways you can treat granuloma annulare is using a potent and effective Herbal Remedies for Granuloma Annulare. Herbal supplements for granuloma annulare include milk thistle, borage oil, dandelion root, red clover extract, burdock root, white willow bark, and St. John’s wort, among others. It would help if you chose a 100% natural herbal supplement that contains only pure herbs without fillers or additives.
ReplyDeleteThe typical symptom of Hydrocele is enlargement or swelling around a testicle.The Natural Remedies for Hydrocele involves surgery to correct any anatomical defect in your child’s scrotum. These additional Herbal Remedies for Hydrocele include herbal medicine like Celdeton Hydrocele.Natural Cure Zone strongly recommends that you consult with your primary healthcare provider before starting any Herbal Supplements.Herbal Supplement for Hydrocele can be treated naturally with herbal supplements.
ReplyDeleteGinger is used as Natural Remedies for Abdominal Adhesions,Turmeric is a well-known herb and Natural Treatment for Abdominal Adhesions discomfort, which can be caused by a variety of factors.It has antispasmodic, cardioprotective, and heart muscle strengthening effects, and it is also Alternative Treatment for Abdominal Adhesions.Herbal Supplement for Abdominal Adhesions, you should seek medical attention.
ReplyDeleteAfter being diagnosed with the problem, Natural Treatment for Abdominal Adhesions should be started right away. Sedeton, a herbal supplement, is the best treatment for it.But if you are afeared from surgical treatment then must try Herbal Supplement for Abdominal Adhesions.. It's also been shown to help regulate bowel motions and ease stomach pains and cramps, which are signs of partial intestinal obstruction caused by abdominal adhesions. Follow the instructions on the package for the most effective Alternative Treatment for Abdominal Adhesions.
ReplyDeleteHey,
ReplyDeleteThis comprehensive tutorial on integrating Microsoft Dynamics AX 2012 with external class libraries and web services is invaluable. The step-by-step instructions and code examples make it easy to follow. Great work!
Data Analytics Courses In Dubai
Your commitment to sharing your knowledge and expertise in this area is greatly appreciated. Thank you for sharing your expertise.
ReplyDeleteData Analytics Courses In Chennai
This thorough guide on use external class libraries and web services with Microsoft Dynamics AXE 2012 is quite helpful. It is simple to follow thanks to the step-by-step instructions and code examples.
ReplyDeleteData Analytics Courses in Agra
The step-by-step instructions and insights you've provided are invaluable for developers and business professionals looking to streamline their operations.
ReplyDeleteDigital marketing courses in illinois
thanks for sharing such well written blog post, great work
ReplyDeleteDigital marketing business
Very well written post. Thanks for sharing.
ReplyDeleteInvestment banking courses after 12th