Showing posts with label Web Service Consume. Show all posts
Showing posts with label Web Service Consume. Show all posts

AIF Services Ax2012




AIF Services In few steps.




Today we learn how to create an AIF service

Step 1
Create a Table and add the below fields.
Fields:
  • Name
  • Phone

Screenshot reference:






Step 2
Create Two classes
  • Student Contract 
  • Student Service

Screenshot reference:





Step 3
Open Student Contract  Class Defines Variable and Create Get Set Method

Screenshot reference:







Step 4
Open Student Service Class

Screenshot reference:



In your student service class create two method
  • Insert Student
  • Get Student

Screenshot reference:



Get Student

Screenshot reference:




Step 5
Set your Student Service Class Run On server

Screenshot reference:




Step 6
Right Click on your project root node and select Service from the Submenu

Screenshot reference:




Step 7
Set the class reference on service properties

Screenshot reference:




Step 8
Then Expend the Service and right-click on the operation and select Add Operation

Screenshot reference:


Step 9
A window will appear now select the method you want to expose to the client in my case I am going to select both methods

Screenshot reference:



Step 10
Right-click on your project and Add a service group

Screenshot reference:




Step 11
Now drag and drop your service into the service group and compile the complete project. after compile right click on the service group and deploy the service group. below window will with deploy result

Screenshot reference:





Step 12
System administration/Area page. 

Screenshot reference:



From the below screen you can find your service External URL

Screenshot reference:





How to Test Service

Step 1
Open Visual Studio
Create a Console application
Step 2
Add Service Reference
Screenshot reference:






Step 3
Add following Code
Screenshot reference:




Step 4
Run Application. Hope the application will be working fine if you follow every step properly. :)

Screenshot reference:

Please feel free to contact me if you are facing any issues during the implementation of this blog.


Support Faryal's Cusine


Dynamics 365 Finance & Operation WebAPI with POST MAN


Dynamics 365 Finance & Operation WebAPI with POSTMAN


Most of the time we used 3rd Party tools like fiddler, Post Man and SoupUI as clients to consume web services.

In this blog i will explain, How can we use POSTMAN to consume Web-API by using Oauth2 Azure Authentication.


Step-1 Download the POSTMAN from this link.

Step-2 Register The Azure Application (Web API). You can follow this link

Step-3 Add the below URL in the Reply URL section https://www.getpostman.com/oauth2/callback. check the below screenshot.



Step-4 Once App registration completed Enter Application ID in D365FO

Reference screenshot



Step-5 Open POST man and navigate to Authorization Tab and select OAuth2 as Authentication Type.

Reference screenshot



Step-6 Click on Get New Access Token. A Popup will appear.

Reference screenshot



Step-7 Fill the required fields Like below

Call Back URL > You can't change this.
Token Name (As per your requirement)
Auth URL

https://login.windows.net/YourTenant.com/oauth2/authorize?resource=https://EnvironmentURL.operations.dynamics.com

Access Token URL
https://login.windows.net/YourTenant.com/oauth2/token?resource=https://EnvironmentURL.operations.dynamics.com

You can find the tenant from AX as well. Open D365FO Click on the Setting icon. you can find it the on the top right of the screen then click on about.





Client ID > Application ID You Registered On Azure Portal
Secret Key > Enter the secret key you generate against your Azure Application.



If you don't provide a secret key then a popup window will appear for login.


Reference Screenshot


Step-8 Click on Request Toke. Within 4 to 5 seconds you will get the Azure Authentication Token.

Step-9  Now select the Header value from the drop-down and click on USE token to add this token in your request.

Reference screenshot



Step-10 Navigate to Header Tabs for the verification of the Authorization token in your request

Reference screenshot


Step-11 Enter the Complete service URL and click on send. in my case, I have called getFoo service.

Reference screenshot



Please check the above screenshot. You will find the successful result 


Please feel free to contact me if you are facing any issues during the implementation of this blog.



Support Faryal's Cusine


Virtual Fields Vs Computed Fields

  Virtual Field: A virtual field in D365FO is a field that doesn't have a direct representation in the database. It's a field that y...