109
Views
4
Comments
XML formatting question
Question

I have the task of exposing a SOAP service in Outsystems that matches an existing (non-Outsystems) service exactly. The idea behind this is that the calling client should only need to change the endpoint to switch over to 'my' service.

I run into a problem that I'll explain with a small example.

The incoming message is a structure (MessageIn) that contains a text attribute (ItemLabel) and an attribute (ItemContents) which is a list of another structure (ItemContent). So the data type of ItemContents is ItemContent List. An ItemContent contains two simple attributes.

When I test my service with this incoming message, I need to put this in the XML to get it parsed correctly by the platform:

      <MessageIn>

        <ItemLabel>string</ItemLabel>

        <ItemContents>

          <ItemContent>

            <ItemWaarde>string</ItemWaarde>

            <ItemBedrag>0</ItemBedrag>

          </ItemContent>

          <ItemContent>

            <ItemWaarde>string</ItemWaarde>

            <ItemBedrag>0</ItemBedrag>

          </ItemContent>

        </ItemContents>

      </MessageIn>

I want to be able to send the following XML to my service, because that's what the original service expects, so with the ItemContents tag removed:

      <MessageIn>

        <ItemLabel>string</ItemLabel>

        <ItemContent>

          <ItemWaarde>string</ItemWaarde>

          <ItemBedrag>0</ItemBedrag>

        </ItemContent>

        <ItemContent>

          <ItemWaarde>string</ItemWaarde>

          <ItemBedrag>0</ItemBedrag>

        </ItemContent>

      </MessageIn>


I don't know how to achieve this. I noticed that the XMLRecords extension has a config setting (RecordMode "C" or "S") in the action RecordToXML that can achieve exactly this when creating XML from a structure. RecordMode "C" will create the first sample above, "S" will create the second one. But what I want to do is the other way around and furthermore I don't know how the access the raw XML before it is parsed by the platform.

Any clues in what direction to look?

2020-02-28 09-46-54
Eduardo Jauch

Hello Gerard,

I have asked the MVPs (let's see if someone has something to say about this) and maybe someone else has already run into this problem and has an easier solution.

But I think the only solution is to use an external web service that will receive the requests and answer in the format required, working as a middle layer (translator) between the requester and the OutSystems web service.

I know that this is far from ideal. But I really fail here in seeing how to do what is needed from a pure OutSystems way...

Let's see if anyone else has some solution for this.

Cheers.

UserImage.jpg
Gerardus Neele

What seems to work, but also far from ideal, is to expose my service as a REST service and just receive the entire SOAP envelope in the request body.

2020-02-28 09-46-54
Eduardo Jauch

Gerard Neele wrote:

What seems to work, but also far from ideal, is to expose my service as a REST service and just receive the entire SOAP envelope in the request body.

Yes. It is a possibility.

Another one is to expose through an Extension. Accordingly to the documentation, this is possible, but I never did it.

In any case, what gives you less headache to implement the logic is the best option.


UserImage.jpg
Gerardus Neele

I'll give the extension option some attention, thanks.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.