AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 01.04.2011, 00:12   #1  
Blog bot is offline
Blog bot
Участник
 
25,631 / 848 (80) +++++++
Регистрация: 28.10.2006
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");
}
We have to put some custom code. In our scenario this is acceptable:

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;
}
If you are interesting how I know what I have to write there. Answer is simple I took a code from class named AxdBase method findList() – it perfectly fit our needs.

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();
}
Run the job, select Endpoint ID, Journal number and click OK. Xml file in outbound channel will be created.



--author: Karel Fischl --editor: Karel Fischl --date: 31/March/2011


Источник: http://blogs.msdn.com/b/emeadaxsuppo...t-service.aspx
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
emeadaxsupport: How to trace AIF Web service SOAP message Blog bot DAX Blogs 0 06.12.2010 16:11
Dianne Siebold: How to Create and Consume a Service – New AIF Webcast Blog bot DAX Blogs 0 19.06.2009 00:08
Pokluda: Outbound web service (AIF) Blog bot DAX Blogs 0 28.10.2006 17:43

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 21:36.