Export Table Data in XML through AIF Document Services

Hi,

I am working on Ax 2012 R3

I have one custom table with two fields Id and Name.

Now I have to export the data through AIF services kindly suggest any idea I am new to services.

Thanks

Haribabu

You can use the document service wizard to create a service, you need a query for that.
technet.microsoft.com/…/aa609947.aspx

Hi Kranthi,

Thanks for your reply.

I have created query and document service through the wizard for the query.

I could generate the xml schema by running the generated job.

Could you please let me know how to export the data into xml by using this service.

Thanks
Haribabu

Create an outbound port by using file system adapter.
technet.microsoft.com/…/hh352313.aspx

In the above link only mentioned about sending the xml data(they have used create service in inbound port) to create sales order.I want to export the data from my custom table as an xml file to create in particular folder from out bound port …

Please let me know which service I need to use is it customservice.read or customservice.create in outbound port…

Please explain…

Thanks
Hari

service.read, service.find

do you mean I need to create to out bound ports?

do you mean I need to create two outbound ports?

One outbound port with two service operations in it. A port can have more than one service operation.

Hi Kranthi,

Understand and created an outbound port with service.find and service.read service operations.

In the data policies I have selected all fields but xml file hasn’t generated in the specified folder.

My custom table dont have any indexes is it mandatory to have index for the table?

Please let me know.

Thanks
Haribabu

If there are no index the system will create RecID index.
msdn.microsoft.com/…/bb278358.aspx

How you are triggering the out bound port? Did you added the batch jobs that are required to send the document?

You can trigger by using the below code,

protected void senByAIF()
{
AifConstraint aifConstraint = new AifConstraint() ;
AifConstraintList aifConstraintList = new AifConstraintList();
AifActionId actionId;
AifEndpointList endpointList = new AifEndpointList();
Query query;

query = new Query(queryStr(YourQuery));

actionId = AifSendService::getDefaultSendAction(classnum(YourServiceClass), AifSendActionType::SendByQuery);

aifConstraint.parmType(AifConstraintType::NoConstraint);
aifConstraintList.addConstraint(aifConstraint);

endpointList = AifSendService::getEligibleEndpoints(actionId, aifConstraintList);

AifSendService::submitFromQuery(actionId, endpointList, query, AifSendMode::Async);
}

I have created batch jobs for two classes those are AifGatewaySendService and AifOutboundProcessingService

is it enough or do I need to run the above job that you suggested?

Thanks
Hari

Have you put anything into the outbound queue? No file will be generated if there is nothing to export.

You need similar code to create send requests.
AifGatewaySendService and AifOutboundProcessingService - these classes processes the send requests

Now Do I need to create record in queue manager ?if yes could you please suggest code ?

No Martin, I haven’t put anything in the queue manager.

Could you please suggest how to create a record in queue manager?

Thanks
Haribabu

You can find an example in documentation: Walkthrough: Deploying the Document Service in an Outbound Exchange [AX 2012].

Thanks Martin …It worked …

Hi Martin, I could create record in queue manager and able to export the data in xml but it is exporting only one record data…kindly give me any to export all the records…the code I used is as below.

AxdSendContext axdSendContext = AxdSendContext::construct();
AifEntityKey aifEntityKey = AifEntityKey::construct();
Map keyData;
AifConstraintList aifConstraintList = new AifConstraintList();
AifConstraint aifConstraint = new AifConstraint();

EMP emp;
;

emp = emp::find(“O1”);

keyData = SysDictTable::getKeyData(emp);

aifEntityKey.parmTableId(emp.TableId);
aifEntityKey.parmRecId(emp.RecId);
aifEntityKey.parmKeyDataMap(keyData);

axdSendContext.parmXMLDocPurpose(XMLDocPurpose::Original);
axdSendContext.parmSecurity(false);

aifConstraint.parmType(AifConstraintType::NoConstraint) ;
aifConstraintList.addConstraint(aifConstraint) ;

AifSendService::submitDefault(
classnum(EmpService),
aifEntityKey,
aifConstraintList,
AifSendMode::Async,
axdSendContext.pack());

Please suggest…