How to send 2 different XML payloads, each with an XML declaration

I need to send the following xml request to a server, as you can see, there’re 2 XML declarations in it. How do I go about this in APIgee Assign Message Policy (or some other kind of policy)?

I tried setting 2 payloads but it deems them as only one xml file (so only one declaration).

<?xml version="1.0"?>
<AccessRequest xml:lang="en-US">
  <AccessLicenseNumber>YourLicenseNumber</AccessLicenseNumber>
  <UserId>YourUserID</UserId>
  <Password>YourPassword</Password>
</AccessRequest>

<?xml version="1.0"?>
<TimeInTransitRequest xml:lang="en-US">
  <Request>
    <TransactionReference>
	<CustomerContext>Your Test Case Summary Description</CustomerContext>
      <XpciVersion>1.001</XpciVersion>
    </TransactionReference>
    <RequestAction>TimeInTransit</RequestAction>
  </Request>
  <TransitFrom>
    <AddressArtifactFormat>
      <PoliticalDivision2>Bishkek</PoliticalDivision2>
      <PostcodePrimaryLow>720001</PostcodePrimaryLow>
      <CountryCode>KG</CountryCode>
    </AddressArtifactFormat>
  </TransitFrom>
  <TransitTo>
    <AddressArtifactFormat>
      <PoliticalDivision2>Phoenix</PoliticalDivision2>
      <PoliticalDivision1>AZ</PoliticalDivision1>
      <PostcodePrimaryLow>85034</PostcodePrimaryLow>
      <PostcodeExtendedLow>6410</PostcodeExtendedLow>
      <CountryCode>US</CountryCode>
    </AddressArtifactFormat>
  </TransitTo>
  <PickupDate>20080630</PickupDate>
  <MaximumListSize>5</MaximumListSize>
  <InvoiceLineTotal>
    <CurrencyCode>USD</CurrencyCode>
    <MonetaryValue>50</MonetaryValue>
  </InvoiceLineTotal>
  <ShipmentWeight>
    <UnitOfMeasurement>
      <Code>KGS</Code>
      <Description>Kilograms</Description>
    </UnitOfMeasurement>
    <Weight>2</Weight>
  </ShipmentWeight>
</TimeInTransitRequest>

1 Like

Ideally, you should fix the problem at the source. What you’re sending is not XML because having more than one XML declaration violates XML’s basic grammar, making the data not well-formed.

You can try using XSLT in Apigee to remove xml declaration,

<xsl:output method="xml" omit-xml-declaration="yes"/>