Mule - XML Array only reads one element - arrays

I have a XML payload that contains the following example:
<Example>
<Brand>
<Id>987S</Id>
<logo>circle</logo>
<Item>
<Name>cologne1</Name>
<Item>
<Name>Bosque</Name>
</Item>
</Item>
<Item>
<Name>t-Shirt</Name>
</Item>
</Brand>
<Brand>
<Id>877823C</Id>
<logo>circle</logo>
<Item>
<Name>t-Shirt2</Name>
<Item>
<Name>t-Shirt black</Name>
<Item>
<Name>t-Shirt black with logo</Name>
</Item>
</Item>
</Item>
</Brand>
</Example>
I read the XML with DataWeave to transform the Example content to Array:
#[payload.Example.*Brand]
It returns a LinkedHashMap with two Objects. I use a for-each to loop and read each Brand object and the result is:
Id: 987S
logo: circle
Item
So, even if the brand object has two Items objects, it only returns one.
How could I solve this?

You should be getting everything under Example tag.

Related

Magento 2: How to Implement Validation in UI-Component with parameters

Ok. Everyone's got an answer on how to add validation rules to a ui-component field via XML. Unfortunately, I can't find anyone that seems to know how to implement a rule that requires a parameter or two. I'm sure the knowledge is out there, but nobody's asked the question. So here it is.
I'm looking to implement the min-words validation rule for a textarea. I've got something like this:
<field name="text_area">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
...
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
<item name="min-words" xsi:type="array">
<item name="length" xsi:type="number">10</item>
</item>
</item>
...
</item>
</argument>
</field>
but I'm guessing, and this doesn't quite work. I'm close, but can't figure out what the "length" parameter is really supposed to be, and looking at the rules.js file doesn't provide any clues.
So for the min-words rule, I found that it's simply:
<item name="min-words" xsi:type="number">10</item>
Having seen other implementations of parameters (not in validation rules), I thought I'd try this for the range-words rule, and discovered this format:
<item name="range-words" xsi:type="array">
<item name="0" xsi:type="number">5</item>
<item name="1" xsi:type="number">10</item>
</item>
This format would serve similar rules that require parameters, such as zip-range, validate-number-range, validate-digits-range, validate-range, validate-date-range, validate-item-quantity, validate-file-type. Being mindful to use the name="0" as array index for each entry.

ova fails to import, seems related to the BootOrderSection tag in the ovf

I've got an ova file that I've created with packer (via this plugin) that imports fine into my local vCenter managed vSphere cluster. I'm on version 6.5. I've got reports that a customer was unable to import this ova into their similar cluster. I don't have any information about what version they're running. Locally, I was able to reproduce their error on an unrelated vSphere 6.5 instance that isn't under vCenter management.
When I try to import the ova, when I'm at the end ready to let it upload the ova, I get the following message:
screenshot of error in vSphere web UI
If I continue anyway, the "upload" completes immediately and produces a VM that takes up no space and won't boot. After 5 minutes of thinking, vSphere seems to decide that it's broken and automatically deletes it.
Interestingly, I tracked it down to the following bit of xml in the ovf file inside the ova:
<vmw:BootOrderSection vmw:instanceId="8" vmw:type="disk">
<Info>Virtual hardware device boot order</Info>
</vmw:BootOrderSection>
If I remove this, update the sha256 value in the manifest file, and re-tar the ova file, that one works fine on both of my environments.
I've attached the entire ovf file from my ova for reference, including what I believe to be the offending BootOrderSection tag.
Any one have any idea what's wrong with my standalone vSphere environment, or my customer's vCenter cluster that isn't showing up on my local vCenter cluster?
The entire ovf that fails:
<?xml version="1.0" encoding="UTF-8"?>
<!--Generated by VMware VirtualCenter Server, User: PD\jprice, UTC time: 2018-10-11T13:58:30.867527Z-->
<Envelope vmw:buildId="build-5973321" xmlns="http://schemas.dmtf.org/ovf/envelope/1" xmlns:cim="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:vmw="http://www.vmware.com/schema/ovf" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<References>
<File ovf:href="safeconnect-disk1.vmdk" ovf:id="file1" ovf:size="3689997824"/>
</References>
<DiskSection>
<Info>Virtual disk information</Info>
<Disk ovf:capacity="300" ovf:capacityAllocationUnits="byte * 2^30" ovf:diskId="vmdisk1" ovf:fileRef="file1" ovf:format="http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized" ovf:populatedSize="6508576768"/>
</DiskSection>
<NetworkSection>
<Info>The list of logical networks</Info>
<Network ovf:name="Services">
<Description>The Services network</Description>
</Network>
</NetworkSection>
<VirtualSystem ovf:id="safeconnect-6.5-ova">
<Info>A virtual machine</Info>
<Name>safeconnect-6.5-ova</Name>
<OperatingSystemSection ovf:id="101" vmw:osType="otherLinux64Guest">
<Info>The kind of installed guest operating system</Info>
<Description>Other Linux (64-bit)</Description>
</OperatingSystemSection>
<VirtualHardwareSection>
<Info>Virtual hardware requirements</Info>
<System>
<vssd:ElementName>Virtual Hardware Family</vssd:ElementName>
<vssd:InstanceID>0</vssd:InstanceID>
<vssd:VirtualSystemIdentifier>safeconnect-6.5-ova</vssd:VirtualSystemIdentifier>
<vssd:VirtualSystemType>vmx-10</vssd:VirtualSystemType>
</System>
<Item>
<rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits>
<rasd:Description>Number of Virtual CPUs</rasd:Description>
<rasd:ElementName>8 virtual CPU(s)</rasd:ElementName>
<rasd:InstanceID>1</rasd:InstanceID>
<rasd:Limit>0</rasd:Limit>
<rasd:ResourceType>3</rasd:ResourceType>
<rasd:VirtualQuantity>8</rasd:VirtualQuantity>
</Item>
<Item>
<rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits>
<rasd:Description>Memory Size</rasd:Description>
<rasd:ElementName>16384MB of memory</rasd:ElementName>
<rasd:InstanceID>2</rasd:InstanceID>
<rasd:Reservation>16384</rasd:Reservation>
<rasd:ResourceType>4</rasd:ResourceType>
<rasd:VirtualQuantity>16384</rasd:VirtualQuantity>
</Item>
<Item>
<rasd:Address>0</rasd:Address>
<rasd:Description>SCSI Controller</rasd:Description>
<rasd:ElementName>SCSI controller 0</rasd:ElementName>
<rasd:InstanceID>3</rasd:InstanceID>
<rasd:ResourceSubType>lsilogic</rasd:ResourceSubType>
<rasd:ResourceType>6</rasd:ResourceType>
<vmw:Config ovf:required="false" vmw:key="slotInfo.pciSlotNumber" vmw:value="16"/>
</Item>
<Item>
<rasd:Address>1</rasd:Address>
<rasd:Description>IDE Controller</rasd:Description>
<rasd:ElementName>IDE 1</rasd:ElementName>
<rasd:InstanceID>4</rasd:InstanceID>
<rasd:ResourceType>5</rasd:ResourceType>
</Item>
<Item>
<rasd:Address>0</rasd:Address>
<rasd:Description>IDE Controller</rasd:Description>
<rasd:ElementName>IDE 0</rasd:ElementName>
<rasd:InstanceID>5</rasd:InstanceID>
<rasd:ResourceType>5</rasd:ResourceType>
</Item>
<Item ovf:required="false">
<rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
<rasd:ElementName>Video card</rasd:ElementName>
<rasd:InstanceID>6</rasd:InstanceID>
<rasd:ResourceType>24</rasd:ResourceType>
<vmw:Config ovf:required="false" vmw:key="enable3DSupport" vmw:value="false"/>
<vmw:Config ovf:required="false" vmw:key="use3dRenderer" vmw:value="automatic"/>
<vmw:Config ovf:required="false" vmw:key="useAutoDetect" vmw:value="false"/>
<vmw:Config ovf:required="false" vmw:key="videoRamSizeInKB" vmw:value="4096"/>
</Item>
<Item ovf:required="false">
<rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
<rasd:ElementName>VMCI device</rasd:ElementName>
<rasd:InstanceID>7</rasd:InstanceID>
<rasd:ResourceSubType>vmware.vmci</rasd:ResourceSubType>
<rasd:ResourceType>1</rasd:ResourceType>
<vmw:Config ovf:required="false" vmw:key="allowUnrestrictedCommunication" vmw:value="false"/>
<vmw:Config ovf:required="false" vmw:key="slotInfo.pciSlotNumber" vmw:value="33"/>
</Item>
<Item>
<rasd:AddressOnParent>0</rasd:AddressOnParent>
<rasd:ElementName>Hard disk 1</rasd:ElementName>
<rasd:HostResource>ovf:/disk/vmdisk1</rasd:HostResource>
<rasd:InstanceID>8</rasd:InstanceID>
<rasd:Parent>3</rasd:Parent>
<rasd:ResourceType>17</rasd:ResourceType>
<vmw:Config ovf:required="false" vmw:key="backing.writeThrough" vmw:value="false"/>
</Item>
<Item>
<rasd:AddressOnParent>7</rasd:AddressOnParent>
<rasd:AutomaticAllocation>true</rasd:AutomaticAllocation>
<rasd:Connection>Services</rasd:Connection>
<rasd:Description>E1000 ethernet adapter on "Services"</rasd:Description>
<rasd:ElementName>Network adapter 1</rasd:ElementName>
<rasd:InstanceID>9</rasd:InstanceID>
<rasd:ResourceSubType>E1000</rasd:ResourceSubType>
<rasd:ResourceType>10</rasd:ResourceType>
<vmw:Config ovf:required="false" vmw:key="slotInfo.pciSlotNumber" vmw:value="32"/>
<vmw:Config ovf:required="false" vmw:key="wakeOnLanEnabled" vmw:value="true"/>
</Item>
<vmw:Config ovf:required="false" vmw:key="cpuHotAddEnabled" vmw:value="false"/>
<vmw:Config ovf:required="false" vmw:key="cpuHotRemoveEnabled" vmw:value="false"/>
<vmw:Config ovf:required="false" vmw:key="firmware" vmw:value="bios"/>
<vmw:Config ovf:required="false" vmw:key="virtualICH7MPresent" vmw:value="false"/>
<vmw:Config ovf:required="false" vmw:key="virtualSMCPresent" vmw:value="false"/>
<vmw:Config ovf:required="false" vmw:key="memoryHotAddEnabled" vmw:value="false"/>
<vmw:Config ovf:required="false" vmw:key="nestedHVEnabled" vmw:value="false"/>
<vmw:Config ovf:required="false" vmw:key="powerOpInfo.powerOffType" vmw:value="soft"/>
<vmw:Config ovf:required="false" vmw:key="powerOpInfo.resetType" vmw:value="soft"/>
<vmw:Config ovf:required="false" vmw:key="powerOpInfo.standbyAction" vmw:value="checkpoint"/>
<vmw:Config ovf:required="false" vmw:key="powerOpInfo.suspendType" vmw:value="hard"/>
<vmw:Config ovf:required="false" vmw:key="tools.afterPowerOn" vmw:value="true"/>
<vmw:Config ovf:required="false" vmw:key="tools.afterResume" vmw:value="true"/>
<vmw:Config ovf:required="false" vmw:key="tools.beforeGuestShutdown" vmw:value="true"/>
<vmw:Config ovf:required="false" vmw:key="tools.beforeGuestStandby" vmw:value="true"/>
<vmw:Config ovf:required="false" vmw:key="tools.syncTimeWithHost" vmw:value="false"/>
<vmw:Config ovf:required="false" vmw:key="tools.toolsUpgradePolicy" vmw:value="manual"/>
<vmw:ExtraConfig ovf:required="false" vmw:key="nvram" vmw:value="safeconnect-6.5-ova.nvram"/>
</VirtualHardwareSection>
<vmw:BootOrderSection vmw:instanceId="8" vmw:type="disk">
<Info>Virtual hardware device boot order</Info>
</vmw:BootOrderSection>
</VirtualSystem>
</Envelope>

Add multiple tracking numbers to an amazon order using MWS API

I am trying to upload multiple tracking numbers to an Amazon order using MWS API in PHP but don't know what would be the XML request for this. Here is the XML I am using which ends up uploading the last tracking number.
$feed = <<<EOD
<?xml version="1.0" encoding="UTF-8"?>
<AmazonEnvelope xsi:noNamespaceSchemaLocation="amzn-envelope.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>XXX</MerchantIdentifier>
</Header>
<MessageType>OrderFulfillment</MessageType>
<Message>
<MessageID>1</MessageID>
<OrderFulfillment>
<AmazonOrderID>$orderId</AmazonOrderID>
<FulfillmentDate>$FulfillmentDate</FulfillmentDate>
<FulfillmentData>
<CarrierCode>$carrierCode</CarrierCode>
<ShipperTrackingNumber>'1Z7X887R0370783509'</ShipperTrackingNumber>
</FulfillmentData>
<Item>
<Quantity>1</Quantity>
</Item>
</OrderFulfillment>
</Message>
<MessageID>2</MessageID>
<OrderFulfillment>
<AmazonOrderID>$orderId</AmazonOrderID>
<FulfillmentDate>$FulfillmentDate</FulfillmentDate>
<FulfillmentData>
<CarrierCode>$carrierCode</CarrierCode>
<ShipperTrackingNumber>'1Z7X887R0075127492'</ShipperTrackingNumber>
</FulfillmentData>
<Item>
<Quantity>1</Quantity>
</Item>
</OrderFulfillment>
</Message>
<MessageID>3</MessageID>
<OrderFulfillment>
<AmazonOrderID>$orderId</AmazonOrderID>
<FulfillmentDate>$FulfillmentDate</FulfillmentDate>
<FulfillmentData>
<CarrierCode>$carrierCode</CarrierCode>
<ShipperTrackingNumber>'1Z7X887R0375972085'</ShipperTrackingNumber>
</FulfillmentData>
<Item>
<Quantity>1</Quantity>
</Item>
</OrderFulfillment>
</Message>
</AmazonEnvelope>
EOD;
Any help is appreciated!
Try the following XML. Hope it helps.
<?xml version="1.0" encoding="UTF-8"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>My Store</MerchantIdentifier>
</Header>
<MessageType>OrderFulfillment</MessageType>
<Message>
<MessageID>1</MessageID>
<OrderFulfillment>
<MerchantOrderID>1234567</MerchantOrderID>
<MerchantFulfillmentID>1234567</MerchantFulfillmentID>
<FulfillmentDate>2002-05-01T15:36:33-08:00</FulfillmentDate>
<FulfillmentData>
<CarrierCode>UPS</CarrierCode>
<ShippingMethod>Second Day</ShippingMethod>
<ShipperTrackingNumber>1Z7X887R0075127492</ShipperTrackingNumber>
</FulfillmentData>
<Item>
<MerchantOrderItemID>11</MerchantOrderItemID>
<MerchantFulfillmentItemID>11</MerchantFulfillmentItemID>
<Quantity>2</Quantity>
</Item>
</OrderFulfillment>
</Message>
<Message>
<MessageID>2</MessageID>
<OrderFulfillment>
<MerchantOrderID>1234567</MerchantOrderID>
<MerchantFulfillmentID>1234567</MerchantFulfillmentID>
<FulfillmentDate>2002-05-01T15:36:33-08:00</FulfillmentDate>
<FulfillmentData>
<CarrierCode>UPS</CarrierCode>
<ShippingMethod>Second Day</ShippingMethod>
<ShipperTrackingNumber>1Z7X887R0075127492</ShipperTrackingNumber>
</FulfillmentData>
<Item>
<MerchantOrderItemID>22</MerchantOrderItemID>
<MerchantFulfillmentItemID>22</MerchantFulfillmentItemID>
<Quantity>2</Quantity>
</Item>
</OrderFulfillment>
</Message>
</AmazonEnvelope>
For more information about XSD, you can refer to Amazon order Fulfilment XSD
Looks like you're not properly opening your messages.
Try this:
</Message>
Add this --> <Message>
<MessageID>2</MessageID>
</Message>
Add this --> <Message>
<MessageID>3</MessageID>
I realize this is an old post, but in case anyone else is looking and can't get the XML to work, I did ultimately find the answer for myself, which was to submit the feed as a flat file instead of XML. My solution was in C# and not PHP, but basically the FeedType has to be set to "POST_FLAT_FILE_FULFILLMENT_DATA"
request.FeedType = "_POST_FLAT_FILE_FULFILLMENT_DATA_";
instead of "POST_ORDER_FULFILLMENT_DATA" and then submit a tab-delimited text file in the format defined here (from their European site, but I use this in the United States marketplace):
https://sellercentral-europe.amazon.com/gp/help/external/help.html?itemID=13491
I tried repeatedly to get the XML to work with a few different variations and simply could not make it work. Amazon's documentation on this is terrible and doesn't describe how to format the XML for multiple tracking numbers. When I switched to the flat file feed, it worked right away. If anyone has had any luck with the XML version, I would be interested in seeing that. I had an open case with Amazon for quite a while trying to get this information from them and they kept insisting that I was asking them to write my code for me when really I just wanted guidance on how to format the XML correctly for their system. I suspect that there is no way to get two tracking numbers to work in and XML feed and that it only works with a flat file.

Unable to submit order fulfilment feed amazon mws

I am trying to update shipping information through the feed API and here is my xml feed
<?xml version="1.0" encoding="UTF-8"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>Merchant id</MerchantIdentifier>
</Header>
<MessageType>OrderFulfillment</MessageType>
<Message>
<MessageID>1</MessageID>
<OrderFulfillment>
<MerchantOrderID>AmazonOrderId</MerchantOrderID>
<FulfillmentDate>2015-05-23T04:57:09+00:00</FulfillmentDate>
<FulfillmentData>
<CarrierCode>Fedex</CarrierCode>
<ShipperTrackingNumber>78066505</ShipperTrackingNumber>
</FulfillmentData>
<Item>
<MerchantOrderItemID>OrderItemId</MerchantOrderItemID>
</Item>
</OrderFulfillment>
</Message>
</AmazonEnvelope>
When I submit the feed getting response as We are unable to process the XML feed because one or more items are invalid. Please re-submit the feed. But both the order id and order item id is valid one.
In the sample feed provided by amazon I can see <MerchantFulfillmentID>1234567</MerchantFulfillmentID> and <MerchantFulfillmentItemID>1234567</MerchantFulfillmentItemID> but where can I find these ids.
As stated here Selling on Amazon Guide to XML:
You can send your own unique order and item identifiers
(MerchantOrderID and MerchantOrderItemID) rather than Amazon's order
and item identifiers, if you established your own in the
OrderAcknowledgement feed.
MerchantOrderID:
Optional seller supplied order ID. The first step is to establish the
MerchantOrderID in the acknowledgem ent feed. Amazon will map the
MerchantOrderID to the AmazonOrderID, and you can then use your own
order ID (MerchantOrderID) for subsequent feeds relating to that
order. See the base XSD for the definition.
MerchantFulfillmentID:
Seller supplied unique identifier for the shipment (not used by Amazon)
If you did not established your own ID´s in the OrderAcknowledgement feed, you can not use this fields in the Order Fulfillment feed.
Instead you have to speficy AmazonOrderID and Item.AmazonOrderItemCode. The AmazonOrderItemCode is an code for this specific product in this specific order. It has nothing todo with the famous ASIN or something.
Working example for an _POST_ORDER_FULFILLMENT_DATA_ feed would like like:
<AmazonEnvelope>
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>M_TESTSHOP_1337</MerchantIdentifier>
</Header>
<MessageType>OrderFulfillment</MessageType>
<Message>
<MessageID>1</MessageID>
<OrderFulfillment>
<AmazonOrderID>110-64133780-1337563</AmazonOrderID>
<FulfillmentDate>2015-11-02T13:02:14</FulfillmentDate>
<FulfillmentData>
<CarrierName>DHL</CarrierName>
<ShippingMethod>Paket</ShippingMethod>
<ShipperTrackingNumber>1337</ShipperTrackingNumber>
</FulfillmentData>
<Item>
<AmazonOrderItemCode>033521337643</AmazonOrderItemCode>
<Quantity>1</Quantity>
</Item>
</OrderFulfillment>
</Message>
</AmazonEnvelope>

Amazon Order Acknowledgment feed

I am using the Order Acknowledgment feed to cancel the order for Amazon. Below is the xml feed format that I am using to cancel the Amazon order.
I have successfully been able to submit this feed to MWS, but every time when I check the feed submission result it always gives this error
'The XML you submitted is ill-formed at the Amazon Envelope XML level
at (or near) line 1, column 485'.
I created the xml format according to this Selling on Amazon: Guide to XML.
<?xml version="1.0"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>M_xxxxxx_108291953</MerchantIdentifier>
</Header>
<MessageType>OrderAcknowledgment</MessageType>
<Message>
<MessageID>1</MessageID>
<OrderAcknowledgement>
<AmazonOrderID>123-1234567-1234567</AmazonOrderID>
<StatusCode>Failure</StatusCode>
<CancelReason>BuyerCanceled</CancelReason>
</OrderAcknowledgment>
</Message>
</AmazonEnvelope>
Can any one help me what i am missing here in the xml format?
There are two problems with your XML code:
Amazon uses "OrderAcknowledgement", not "OrderAcknowledgment". While that choice may be debatable, the XSDs do not leave any room for a different spelling. (this applies to the MessageType and both opening and closing XML tag, your spelling is correct for the opening tag only)
CancelReason is only valid inside <Item> substructures.
The following XML validates:
<?xml version="1.0"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>M_xxxxxx_108291953</MerchantIdentifier>
</Header>
<MessageType>OrderAcknowledgement</MessageType>
<Message>
<MessageID>1</MessageID>
<OrderAcknowledgement>
<AmazonOrderID>123-1234567-1234567</AmazonOrderID>
<StatusCode>Failure</StatusCode>
<Item>
<AmazonOrderItemCode>12345678901234</AmazonOrderItemCode>
<CancelReason>BuyerCanceled</CancelReason>
</Item>
<Item>
<AmazonOrderItemCode>12345678901235</AmazonOrderItemCode>
<CancelReason>BuyerCanceled</CancelReason>
</Item>
<Item>
<AmazonOrderItemCode>12345678901237</AmazonOrderItemCode>
<CancelReason>BuyerCanceled</CancelReason>
</Item>
</OrderAcknowledgement>
</Message>
</AmazonEnvelope>

Resources