Document service schema inflexible?

Hello,

I have another program sending an information dump in XML format. I’m supposed to have AX read it, discover what information has changed by comparing it with the database, and then process the changes. I created a class, a query, then used some wizard to make a document service. With an inbound port and a batch job it’s consuming my messages alright. But I couldn’t find any way of getting the schema of the document service to match the input - and I cannot change the format of the input file to match what AX expects. It seems to me that the message reader expects certain tags like body and header and things, and it interpreted my class variables as elements whereas the input message has them as attributes. So I wasn’t surprised to get ‘Invalid message schema’ exceptions. For reference, here’s my input file:


There are about 6000 records (tasks) in the file. At this point I’m not sure if I care about making the schemas fit, if necessary I’ll do the text manipulation myself. To this end, I’m preparing to modify the AIFMessage.deserialize method, however this all seems like a awfully clumsy approach and before I proceed any further I was wondering if there’s a way to proceed that offers greater finesse. I tried a custom service but wasn’t able to make anything work or find anything that seemed to fit my situation.

Elements like Envelope, Body and so on are defined by the SOAP standard, because we’re talking about a SOAP service. You clearly can’t change the standard; you have to provide a valid SOAP message.

The content of Body is defined in AX and you have some ways how to influence it, but it closely follow the definition of your query.

Therefore trying to change the schema to match an arbitrary format from another system isn’t a viable approach. What you need is a transformation from one schema to another.

Thank you Martin. I’ve spent some time looking over XSL tranformations and planning that out. The one that was most useful was this blog because he’s doing a list to list transformation: http://deepakdyanmicsax.blogspot.com/2016/03/aif-xslt-transformation.html. But I’ve run into another problem. My input file has thousands of records, but Axapta only expects one.

This is what I have for my schema:

<?xml version="1.0" encoding="utf-16"?>

<xs:schema xmlns:tns="schemas.microsoft.com/…/Tem_PrintflowTask" xmlns:st="schemas.microsoft.com/…/sharedtypes" elementFormDefault=“qualified” targetNamespace="schemas.microsoft.com/…/Tem_PrintflowTask" xmlns:xs=“www.w3.org/…/XMLSchema">
<xs:import schemaLocation=“SharedTypes.xsd” namespace=“schemas.microsoft.com/…/sharedtypes" />
<xs:element name=“Tem_PrintflowTask” type=“tns:AxdTem_PrintflowTask” />
<xs:complexType name=“AxdTem_PrintflowTask”>
xs:sequence
<xs:element minOccurs=“0” name=“DocPurpose” nillable=“true” type=“st:AxdEnum_XMLDocPurpose” />
<xs:element minOccurs=“0” name=“SenderId” nillable=“true” type=“st:AxdExtType_DataAreaId” />
<xs:element minOccurs=“0” maxOccurs=“unbounded” name=“PF_InboundTask” type=“tns:AxdEntity_PF_InboundTask” />
</xs:sequence>
</xs:complexType>
<xs:complexType name=“AxdEntity_PF_InboundTask”>
xs:sequence
<xs:element minOccurs=“0” name=”_DocumentHash” nillable=“true” type=“xs:string” />
<xs:element minOccurs=“0” name=“RecId” nillable=“true” type=“st:AxdExtType_RecId” />
<xs:element minOccurs=“0” name=“RecVersion” nillable=“true” type=“st:AxdExtType_RecVersion” />
<xs:element minOccurs=“0” name=“Job_Code” nillable=“true” type=“xs:string” />
<xs:element minOccurs=“0” name=“Form_Code” nillable=“true” type=“xs:string” />
<xs:element minOccurs=“0” name=“NumberOfRuns” nillable=“true” type=“xs:string” />
<xs:element minOccurs=“0” name=“ColorSplit” nillable=“true” type=“xs:string” />
<xs:element minOccurs=“0” name=“NumberOfSplits” nillable=“true” type=“xs:string” />
<xs:element minOccurs=“0” name=“JDF_Submit_Time_Buffer” nillable=“true” type=“xs:string” />
<xs:element minOccurs=“0” name=“Inline” nillable=“true” type=“xs:string” />
<xs:element minOccurs=“0” name=“Switchover_Duration” nillable=“true” type=“xs:string” />
<xs:element minOccurs=“0” name=“Run_Duration” nillable=“true” type=“xs:string” />
<xs:element minOccurs=“0” name=“Setup_Duration” nillable=“true” type=“xs:string” />
<xs:element minOccurs=“0” name=“EndRunDate” nillable=“true” type=“xs:string” />
<xs:element minOccurs=“0” name=“Start_Setup_Date” nillable=“true” type=“xs:string” />
<xs:element minOccurs=“0” name=“CC_Code” nillable=“true” type=“xs:string” />
<xs:element minOccurs=“0” name=“Operation_Code” nillable=“true” type=“xs:string” />
</xs:sequence>
<xs:attribute fixed=“entity” name=“class” use=“required” />
<xs:attribute name=“action” type=“st:AxdEnum_AxdEntityAction” />
</xs:complexType>
</xs:schema>

Is there a way I can modify the Query so that the document service wizard knows I expect it to return multiple results? I’ve had a lot of trouble finding a suitable demo for this. I can tell from Deepak’s blog that it can be done, but he doesn’t show how the AX side is created. I’ve tried to follow this blog as well: https://community.dynamics.com/ax/b/brandongeorge/archive/2011/09/20/ax-2012-and-a-look-at-some-more-complex-datacontract-concepts-and-usage but wasn’t able to get it to work.

I’m not sure why you’re trying to change anything in the document service wizard. It seems that you’re trying to fix a non-existing problem, because you (incorrectly) believe that one SOAP message can’t contain data for multiple entities.

For example, a single request message for SalesSalesOrderService.create can contain many SalesTable nodes under the SalesOrder node. Try it and you’ll see it by yourself.