AIF Document Services ကို Dynamics AX 2012 တွင် X++ မှ တိုက်ရိုက်ခေါ်ဆိုခြင်း။
ထုတ်ဝေသည်- ၂၀၂၅၊ ဖေဖော်ဝါရီ ၁၆ UTC ၁၁:၂၆:၂၄
နောက်ဆုံး မွမ်းမံပြင်ဆင်သည်- ၂၀၂၆၊ ဇန်နဝါရီ ၁၂ UTC ၀၈:၅၅:၄၃
ဤဆောင်းပါးတွင်၊ Dynamics AX 2012 ရှိ Application Integration Framework document service များကို X++ ကုဒ်မှ တိုက်ရိုက်ခေါ်ဆိုနည်းကို ရှင်းပြထားပြီး၊ inbound နှင့် outbound call နှစ်မျိုးလုံးကို တုပခြင်းဖြင့် AIF ကုဒ်ရှိ အမှားများကို ရှာဖွေပြီး debug လုပ်ရန် သိသိသာသာ ပိုမိုလွယ်ကူစေပါသည်။
Calling AIF Document Services Directly from X++ in Dynamics AX 2012
ဤပို့စ်ရှိ အချက်အလက်များသည် Dynamics AX 2012 R3 ကို အခြေခံထားသည်။ အခြားဗားရှင်းများအတွက် မှန်ကန်နိုင်သည် သို့မဟုတ် မမှန်ကန်နိုင်ပါ။
မကြာသေးခင်က ကျွန်တော်ဟာ တခြားစနစ်တစ်ခုက ရရှိတဲ့ဒေတာအပေါ်အခြေခံပြီး ဖောက်သည်တွေဖန်တီးဖို့အတွက် Application Integration Framework (AIF) inbound port တစ်ခုကို ဖောက်သည်တစ်ယောက် အကောင်အထည်ဖော်ရာမှာ ကူညီပေးနေခဲ့ပါတယ်။ Dynamics AX က CustCustomer document service ကို ပံ့ပိုးပေးထားပြီးဖြစ်ပြီး ဒီအတွက် logic ကို အကောင်အထည်ဖော်ပေးတဲ့အတွက် ကျွန်တော်တို့က ဒါကို ရိုးရှင်းအောင်ထားပြီး standard solution ကိုသုံးဖို့ ဆုံးဖြတ်ခဲ့ပါတယ်။
သို့သော်လည်း၊ မကြာမီတွင် Dynamics AX လက်ခံမည့် XML ကို ပြင်ပစနစ်မှ ထုတ်ပေးရာတွင် အခက်အခဲများစွာရှိနေကြောင်း တွေ့ရှိခဲ့ရသည်။ Dynamics AX မှ ထုတ်လုပ်သော XML schema သည် အတော်လေး ရှုပ်ထွေးပြီး Dynamics AX တွင် bug အနည်းငယ်သာရှိပြီး အခြား tool များအရ schema-valid ဖြစ်သော XML ကို ငြင်းပယ်စေသည့်ပုံပေါ်သောကြောင့် အားလုံးကို ခြုံငုံကြည့်လျှင် ကျွန်ုပ်ထင်ထားသည်ထက် မရိုးရှင်းကြောင်း သက်သေပြခဲ့သည်။
ကြိုးပမ်းအားထုတ်မှုအတွင်းမှာ AIF က ပေးထားတဲ့ error message တွေက သတင်းအချက်အလက် သိပ်မပေးတာကြောင့် XML ဖိုင်တချို့နဲ့ ပတ်သက်ပြီး ဘာပြဿနာရှိလဲဆိုတာကို ကျွန်တော် မကြာခဏ နားလည်ရခက်ခဲ့ပါတယ်။ ပြင်ပစနစ်က MSMQ ကနေ message အသစ်တစ်ခု ပို့ဖို့နဲ့ AIF က message ကို ကောက်ယူပြီး error မမြင်ရခင်မှာ ထပ်စောင့်ရတာကြောင့်လည်း ပင်ပန်းပါတယ်။
ထို့ကြောင့် ပိုမိုမြန်ဆန်သော စမ်းသပ်မှုအတွက် ဒေသတွင်း XML ဖိုင်ဖြင့် ဝန်ဆောင်မှုကုဒ်ကို တိုက်ရိုက်ခေါ်ဆိုနိုင်မလားဟု ကျွန်ုပ် စုံစမ်းစစ်ဆေးခဲ့ပြီး ၎င်းသည် ဖြစ်နိုင်ကြောင်း တွေ့ရှိခဲ့သည် - ထို့အပြင် ၎င်းသည် လုပ်ဆောင်ရန် အလွန်ရိုးရှင်းပြီး အမှန်တကယ်တွင် ပိုမိုအဓိပ္ပာယ်ရှိသော error message များကို ပေးစွမ်းသည်။
အောက်ဖော်ပြပါ ဥပမာအလုပ်သည် ဒေသတွင်း XML ဖိုင်တစ်ခုကို ဖတ်ပြီး AxdCustCustomer ဝန်ဆောင်မှုမှ အသုံးပြုသော document class နှင့်အတူ ဖောက်သည်တစ်ဦး ဖန်တီးရန် ကြိုးစားသည်။ လိုအပ်ပါက အခြား document class အားလုံးအတွက် အလားတူအလုပ်များကို သင်ပြုလုပ်နိုင်သည်၊ ဥပမာ AxdSalesOrder။
{
FileNameOpen fileName = @'C:\\TestCustomerCreate.xml';
AxdCustomer customer;
AifEntityKey key;
#File
;
new FileIoPermission(fileName, #IO_Read).assert();
customer = new AxdCustomer();
key = customer.create( XmlDocument::newFile(fileName).xml(),
new AifEndpointActionPolicyInfo(),
new AifConstraintList());
CodeAccessPermission::revertAssert();
info('Done');
}
customer.create() method မှ ပြန်ပေးသော AifEntityKey object (AIF ရှိ "create" service operation နှင့် ကိုက်ညီသည်) တွင် မည်သည့် customer ကို ဖန်တီးခဲ့သည်ဆိုသည့် အချက်အလက်များအပြင် ဖန်တီးထားသော CustTable မှတ်တမ်း၏ RecId ပါဝင်သည်။
သင်စမ်းသပ်ရန်ကြိုးစားနေသည်မှာ Outbound port တစ်ခုဖြစ်ပါက သို့မဟုတ် Inbound port တွင် XML မည်သို့ဖြစ်သင့်သည်ကို ဥပမာတစ်ခုသာ လိုအပ်ပါက၊ read() method ("read" service operation နှင့်ကိုက်ညီသော) ကိုခေါ်ဆိုခြင်းဖြင့် document class ကို အသုံးပြု၍ customer ကို file တစ်ခုသို့ export လုပ်နိုင်သည်။
{
FileNameSave fileName = @'C:\\TestCustomerRead.xml';
Map map = new Map( Types::Integer,
Types::Container);
AxdCustomer customer;
AifEntityKey key;
XMLDocument xmlDoc;
XML xml;
AifPropertyBag bag;
#File
;
map.insert(fieldNum(CustTable, AccountNum), ['123456']);
key = new AifEntityKey();
key.parmTableId(tableNum(CustTable));
key.parmKeyDataMap(map);
customer = new AxdCustomer();
xml = customer.read(key,
null,
new AifEndpointActionPolicyInfo(),
new AifConstraintList(),
bag);
new FileIoPermission(fileName, #IO_Write).assert();
xmlDoc = XmlDocument::newXml(xml);
xmlDoc.save(fileName);
CodeAccessPermission::revertAssert();
info('Done');
}
'၁၂၃၄၅၆' ကို သင်ဖတ်ရှုလိုသော ဖောက်သည်၏ အကောင့်နံပါတ်ဖြင့် အစားထိုးသင့်သည်။
နောက်ထပ်စာဖတ်ခြင်း။
ဤပို့စ်ကို သင်နှစ်သက်ပါက၊ ဤအကြံပြုချက်များကို သင်လည်း နှစ်သက်နိုင်ပါသည်-
- Dynamics AX 2012 တွင် X++ ကုဒ်မှ Enum ၏ဒြပ်စင်များကို မည်သို့ပြန်ဆိုရမည်နည်း။
- Dynamics AX 2012 ရှိ data() နှင့် buf2Buf() ကွာခြားချက်
- Dynamics AX 2012 SysOperation Framework အမြန်ခြုံငုံသုံးသပ်ချက်
