I will be talking about Microsoft Dynamics AX development, x ++, training, tips and tricks,add-ons and tutorials, AIF integration, SSRS reporting, best practices, EP, workflow, troubleshooting, design patterns and any upcoming news and enhancements.
This article is about creating inbound web service. Let’s go through step by step to understand the development of it.
First we will discuss the concepts then we will go deeper in the implementation.
How the component are interacting with each other
Steps to develop a web service
1. Create a query
a. Remember to prefix it with Axd
b. Add the fields in this query that you want to expose to the user
c. Right click the fields property and set it to “No”.
d. Remember to delete ‘_1′ suffix from the data source’s name
2. Go to tools –> Wizard –> Aif Document wizard
3. For the inbound service, you need to check the “create” check box, since the inbound service will be creating the record. For generating AxBc class, just click the Generate Axbc check.
4. On finishing this wizard, you would have the project with the axbc and Axd classes.
5. Remove the cache method from the axbc class to remove the error
6. Your web service is ready
7. Right click the service and click addins –> register service.
8. Create a inbound port to expose this service
Some important method
Where to write code for the validations and saving?
Axd**** class –> prepareForSaveExtended() method is the place to write that type of code. This method is called twice for each data source, first time before saving record, then after saving the record
You can write code like below for your validation and saving the records.
axCustable= _axBcStack.top(); switch (_recordProcessingContext)
// Ensure CustTable record is saved before any of its dependent child records
// Ensure CustTable record is saved
How to default Value in the webservice?
Write the code for it in the Ax***** classes for your document. Use the parmMethods to do that. The code some thing like below will be good example
protected void setIsTestField()
if (this.isMethodExecuted(funcName(), fieldNum(TestTable, IsTestField))
How to make fields not required or un mandatory on the web service?
If you have a field that is mandatory on the table but you want those fields to be not required on the class, you have to override the initMandatoryFieldExemptionList() on the Ax*** class. For instance, for custTable, over ride the method in AxCustTable class and write code like below
protected void initMandatoryFieldsExemptionList()
How to make fields mandatory on the web service?
If you have a field that is not mandatory on the table but you want those fields to be required on the webservice, you have to override the initMandatoryFieldMap() on the AxD*** class. For instance, for custTable, over ride the method in AxDCustTable class and write code like below
Do we have reference group type functionality on the Web service?
If you have foreign key of some table in your document table, you probably don’t want that record id to be taken as input from the user, and you probably be looking for the user understandable value from him. For that type of functionality, you have to override the expandSurrogateKey(…) method on your Axd class and make a natural key on the foreign key table. This natural key would be shown to the user.
I want to write customized code that could resolve surrogate key ?
Over ride the getForiegnkeyValue (..) method on your Axd class and you can write code like below to resolve the references
ret = super(_axdBaseProperty, _sfkReplacementValue);
case tableNum(TestTable) :
case fieldNum(TestTable, TestField):
ret = TestTable::Find(_sfkReplacementValue.value(‘TestNaturalKeyName’)).RecId).RecId;
Other Microsoft Sites
I'm a Customer
I'm a Partner
Use the official Twitter tags:
#MSDYNCOMM | #CONV13