Code to trigger outbound service AX AF 2012
We often get the requirement to export the the xml file for a particular document using outbound port. Outbound port can be triggered normally through AIF gateway classes in batch. Further their are requirements where we may need to generate the XML using outbound port on any particular event.
Below is the code which can be placed on any event handler to trigger a outbound port configured for the XML document.
Sample X ++ code:
We often get the requirement to export the the xml file for a particular document using outbound port. Outbound port can be triggered normally through AIF gateway classes in batch. Further their are requirements where we may need to generate the XML using outbound port on any particular event.
Below is the code which can be placed on any event handler to trigger a outbound port configured for the XML document.
Sample X ++ code:
public client server static void OutboundFileSytemAdapterInvokeJob(XppPrePostArgs _args) { SalesTable salesTable; AxdSendContext axdSendContext = AxdSendContext::construct(); Map keyData; ClassId serviceClass; AifConstraint aifConstraint = new AifConstraint(); AifConstraintList aifConstraintList = new AifConstraintList(); AifActionId actionId; AifEndpointList endpointList; AIFGatewaySendService aIFGatewaySendService = new AIFGatewaySendService(); AifEntityKey aifEntityKey = AifEntityKey::construct(); #define.xmlServiceRead('SalesSalesOrderService.read') salesTable= _args.getThis(); if(salesTable.RecId) { keyData = SysDictTable::getKeyData(salesTable); aifEntityKey.parmTableId(salesTable.TableId); aifEntityKey.parmRecId(salesTable.RecId); aifEntityKey.parmKeyDataMap(keyData); axdSendContext.parmXMLDocPurpose(XMLDocPurpose::Original); axdSendContext.parmSecurity(false); serviceClass = className2Id(classStr(SalesSalesOrderService)); aifConstraint.parmType(AifConstraintType::NoConstraint); aifConstraintList.addConstraint(aifConstraint); if(serviceClass) { //Get the actionId of the default action for this document class actionId = AifSendService::getDefaultSendAction(serviceClass, AifSendActionType::SendByKey); actionId = xmlServiceRead; if(actionId) { //Get the list of valid Endpoints endpointList = AifSendService::getEligibleEndpoints(actionId, aifConstraintList); AifSendService::submit(actionId,endpointList,aifEntityKey,AifSendMode::Sync,axdSendContext.pack(),AifProcessingMode::Parallel); } } AIFGatewaySendService.run();} }
}
No comments:
Post a Comment