Inbound Support

Let's say you have an existing CSV inbound interface in the Bookstore module. It contains 4 fields: Title, PublishedDate, Rating, and PublisherAddress.

images/download/attachments/144836108/csv_inbound_interface-version-1-modificationdate-1645137316000-api-v2.png

Sample data in CSV format:

#* Title,Published Date (MM/dd/yyyy),"Rating (#,#.#####)",PublisherAddress
Introduction To Platform,04/02/2014,9
Platform User Guide,04/02/2014,10,US~TX~Dallas~~~~4055 Valley View Ln~~~75000~~~
Using CSV-as-XML support, Platform can support the same interface using the following XML format:
 
<?xml version="1.0" encoding="UTF-8"?>
<ZBKS.BookLoad version="1.0">
<Record>
<Title>Introduction To Platform</Title>
<PublishedDate>04/02/2014</PublishedDate>
<Rating>9</Rating>
<PublisherAddress>
<Country>US</Country>
<Component Type="STATE">TX</Component>
<Component Type="CITY">Dallas</Component>
<Component Type="STREET1">4055 Valley View Ln</Component>
<Component Type="ZIP">75000</Component>
</PublisherAddress>
</Record>
<Record>
<Title>Platform User Guide</Title>
<PublishedDate>04/02/2014</PublishedDate>
<Rating>10</Rating>
<PublisherAddress>
<Country>CANADA</Country>
<Component Type="PROVINCE">Ontario</Component>
<Component Type="CITY">Toronto</Component>
<Component Type="STREET1">123 Test Street West</Component>
<Component Type="POSTAL_CODE">A1A 1A1</Component>
</PublisherAddress>
</Record>
</ZBKS.BookLoad>
    
Note how the entire file is contained in a root element which matches the name of the interface (ZBKS.BookLoad). Then there is a Record element for each "row" of input, where each Record has a field named as per the CSV interface to hold the data.    

To process data in XML format above, you need to define a MessageTransform with TransformClass "com.transcendsys.platform.integ.message.InboundXMLToCsvTransform". (This is in addition to any MessageQueue, MessageSource, MessageSourcePoll, and Grid configuration you would use for any interface.)

After the message has been enqueued and the dequeue happens for processing, the transformer gets invoked. It transforms the XML file to CSV. Platform processes the CSV using the CSV framework and enqueues the success or error CSV message to the response queue.

If the incoming XML is not properly formatted, an error response will be enqueued and the task will fail.

Also if you have identically named field across levels in the interface (e.g. State for both ShipmentHeader and ShipmentLine), then the element name in the XML should be qualified with the level name. For example:

<?xml version="1.0" encoding="UTF-8"?>
<ZBKS.Shipment_IB version="1.0">
<Record>
<ShipmentNumber>ShipmentNumber9003</ShipmentNumber>
<CreationOrganizationName>SampleOrg</CreationOrganizationName>
<CreationEnterpriseName>SampleEnterprise</CreationEnterpriseName>
<ShipmentHeader.State>Awaiting</ShipmentHeader.State>
<ShipmentLineNumber>ShipmentLineNumber1</ShipmentLineNumber>
<ItemName>SampleItem1</ItemName>
<ShipmentLine.State>Open</ShipmentLine.State>
</Record>
</ZBKS.Shipment_IB>

Success Response

When CSV processing is successful, Platform enqueues an empty message to the success response queue. But for XML, we need the response to be in XML format. To make this work, define another MessageTransform for Enqueue with TransformClass as "com.transcendsys.platform.integ.message.OutboundCsvToXMLTransform".

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ModelList xmlns="http://www.onenetwork.com/Platform">
<ValueChainId>9123</ValueChainId>
<CustomModelName>Standard MessageTransform</CustomModelName>
<ActionName>PLT.Create</ActionName>
<MessageTransform>
<ValueChainId>9123</ValueChainId>
<InboundQueueValueChainId>9123</InboundQueueValueChainId>
<InboundQueueName>outbox/Bookstore/success</InboundQueueName>
<OutboundInterface>ZBKS.BookLoad/success</OutboundInterface>
<TransformClass>com.transcendsys.platform.integ.message.OutboundCsvToXMLTransform</TransformClass>
<TransformOn>Enqueue</TransformOn>
<Precedence>1</Precedence>
</MessageTransform>
</ModelList>


Please note the InboundQueueName and OutboundInterface in the MessageTransform XML, suffixed with "/success".

When executed, OutboundCsvToXMLTransform will generate an empty XML message for an empty CSV success response.


<?xml version="1.0" encoding="UTF-8"?>
<ZBKS.BookLoad version="1.0"/>

Error Response

If processing is not successful because required fields are missing, permission issues were encountered or due to business logic errors, platform enqueues an error CSV message to the error response queue. Again, to generate an outbound error response in XML, define a MessageTransform for Enqueue with TransformClass as "com.transcendsys.platform.integ.message.OutboundCsvToXMLTransform".

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ModelList xmlns="http://www.onenetwork.com/Platform">
<ValueChainId>9123</ValueChainId>
<CustomModelName>Standard MessageTransform</CustomModelName>
<ActionName>PLT.Create</ActionName>
<MessageTransform>
<ValueChainId>9123</ValueChainId>
<InboundQueueValueChainId>9123</InboundQueueValueChainId>
<InboundQueueName>outbox/Bookstore/error</InboundQueueName>
<OutboundInterface>ZBKS.BookLoad/error</OutboundInterface>
<TransformClass>com.transcendsys.platform.integ.message.OutboundCsvToXMLTransform</TransformClass>
<TransformOn>Enqueue</TransformOn>
<Precedence>1</Precedence>
</MessageTransform>
</ModelList>


Please note the InboundQueueName and OutboundInterface in the MessageTransform XML, suffixed with "/error".

When executed, the OutboundCsvToXMLTransform will generate an XML error message for a CSV error message. Note the RecordNumber (roughly equivalent to row number in CSV) and Error (processing error detail message) in the Error response.

<?xml version="1.0" encoding="UTF-8"?>
<ZBKS.BookLoad version="1.0">
<Record>
<RecordNumber>1</RecordNumber>
<Error>Missing required field Title</Error>
<Title/>
<PublishedDate>04/02/2014</PublishedDate>
<Rating>9</Rating>
</Record>
</ZBKS.BookLoad>