orbeon

Orbeon - dynamic XML in POST request body


I need help with body of POST request. I need send XML whitch can be dynamically assemble. Not only putting values in elements. I work with Orbeon 2021.1.2 PE. There are two cases I came across when connecting to my backend and they are quite similar:

1] There is a array in the request where its length is based on the data in the form.

When using a request template:

<SendAction>
  <IDs>
    <ID></ID>
  </IDs>
</SendAction>

You can simply put a value using //ID and the result is this:

<SendAction>
  <IDs>
    <ID>AAA</ID>
  </IDs>
</SendAction>

But I would need a request when the number of <ID> is N like:

<SendAction>
  <IDs>
    <ID>AAA</ID>
    <ID>BBB</ID>
    <ID>CCC</ID>
  </IDs>
</SendAction>

2] The request again has a dynamically long array but I need put entire object. E.g:

 <Wheapons>
    <Weapon>
        <LicenseNumber>123456789</LicenseNumber>
        <Name>Gun A</KindOfWeapon>
        <Category>0</Category>
    </Weapon>
    <Weapon>
        <LicenseNumber>987654321</LicenseNumber>
        <Name>Gun B</KindOfWeapon>
        <Category>0</Category>
    </Weapon>
<Wheapons>

I hope you get my point. Data in second example I have in fr:dataset() and in Repeated Grid too (it is output of diferent endpoint). I tried to insert whole blocks of XML, but Orbeon always encode the characters in xml ('<' to "& lt;" and '>' to "& gt;") and therefore the request is not processed. This behavior is basically good, because I'm trying something like XML injection. But I achieve the same bad result when using the xf:element() function. Is this problem solvable by some funcitons or I'm complete wrong? Thank you!


Solution

  • My understanding is that your form has a repeated grid, and that you would like to call a service POSTing XML to that service based on the values of fields inside a repeated grid. This isn't something that you can do with the Services & Actions in Form Builder; currently, those only let you send individual values to a service. So, instead, you'll need to write that logic in XForms. At a high level: