|
01.04.2011, 00:12 | #1 |
Участник
|
emeadaxsupport: How to: Add a new operation to AIF Document Service.
Источник: http://blogs.msdn.com/b/emeadaxsuppo...t-service.aspx
============== There are couple of document services in AX without all standard operation out of the box. A lot of time there is a need to get a sample of create operation. Usually in that situations we get a read (or find) operation to read data and then use this response as a basic template for create (or update) operation. But what we can do in situations when there is only create method? (Our sample will be LedgerPurchaseInvoiceService) First we need to update document service class. Open menu: Tools –> Development tools –> Application Integration Framework –> Update document service. Select a proper class name – in our sample LedgerPurchaseInvoiceService. In form will be displayed service operations already existed in this service. We will check “find” operation and then also “regenerate data object classes”. A project with name “AxdPurchaseInvoice” will be generated. Now, go to AOT and find Services –> LedgerPurchaseInvoiceService –> Operations. Right click and select “Add Operation”. Mark our new operation and click OK. Save service and open AxdPurchaseInvoice project. Good practice is to add Services –> LedgerPurchaseInvoiceService to this project to keep all necessary on one place. Locate in class AxdPurchaseInvoice method “findList”. Original one will look like: X++: public AifDocumentXml findList(AifQueryCriteria _queryCriteria, AifSchemaInfo _xsdInfo, AifEndpointActionPolicyInfo _actionPolicyInfo, AifConstraintListCollection _constraintListCollection, AifPropertyBag _aifPropertyBag) { ; throw error("@SYS94920"); } X++: public AifDocumentXml findList( AifQueryCriteria _queryCriteria, AifSchemaInfo _xsdInfo, AifEndpointActionPolicyInfo _actionPolicyInfo, AifConstraintListCollection _constraintListCollection, AifPropertyBag _aifPropertyBag) { AifDocumentXml xmlString; AxdBaseRead axdBaseRead; ; // Set AIF fault context this.setAifFaultContext(#DocumentOperation_Find); // Get send context properties this.unpackPropertyBag(_aifPropertyBag); // Construct the read class axdBaseRead = AxdBaseRead::construct(); axdBaseRead.parmAxdBase(this); axdBaseRead.parmQueryCriteria(_queryCriteria); if (_xsdInfo) { // Schema caching is not yet implemented in the reader axdBaseRead.parmFilterXSD(_xsdInfo.parmSchemaXml()); axdBaseRead.parmSchemaId(_xsdInfo.parmSchemaId()); } else { axdBaseRead.parmFilterXSD(''); } axdBaseRead.parmAifEndpointActionPolicyInfo(_actionPolicyInfo); axdBaseRead.parmConfigRecId(AifEndpointActionValueMap::find(_actionPolicyInfo.parmEndpointId(), _actionPolicyInfo.parmActionId()).RecId); // Find the document xmlString = axdBaseRead.findDocumentList(_constraintListCollection); return xmlString; } Now we need to set up this new operation service in AIF configuration. I am expecting that you already have AIF File System adapter setup and working. First make sure that your LergerPurchaseInvoiceService is enabled in AIF Services form. You need to click Refresh on this form too – to let AX know that new operation is prepared. Now open Endpoints form and select Action policies and click new – select LedgerPurchaseInvoiceService.find and be sure to enable it. Then you have to check Data policies form and enable fields which you want (need). You need to open this form at least once to generate XSD file. And final step just to create simple call by job. We can use following code: X++: static void AxdSendPlusProcess(Args _args) { AxdSend axdSend; AifConstraintList aifConstraintList; AifConstraint aifConstraint; AifOutboundProcessingService aiop = new AifOutboundProcessingService(); AifGatewaySendService agss = new AifGatewaySendService(); ; axdSend = new AxdSend(); aifConstraintList = new AifConstraintList(); aifConstraint = new AifConstraint(); aifConstraint.parmType(AifConstraintType::NoConstraint); aifConstraintList.addConstraint(aifConstraint); axdSend.parmShowDocPurpose(false); axdSend.sendMultipleDocuments(classnum(LedgerPurchaseInvoice), classnum(LedgerPurchaseInvoiceService), AifSendMode::Sync, aifConstraintList); aiop.run(); agss.run(); } --author: Karel Fischl --editor: Karel Fischl --date: 31/March/2011 Источник: http://blogs.msdn.com/b/emeadaxsuppo...t-service.aspx
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|