Add a new XML segment at runtime ?

Hello.

i have an incoming XML message. At runtime and depending on some conditions i must add some segments and several hierarchy levels.

What will be the best approach for doing so ?

I just thought about a LOOP step, an external .NET service with a LINQ logic, a java service,…

But i dont find a ESB service for adding a new xml segment or node to a existing xml document.

Thanks for your ideas :slight_smile:

BR,
Sebastian

Hi,

you can try the following approach.

  1. create the document type using xml schema
  2. convert the xml string to document and map to the document type generated in step 1
  3. map the new data to the document
  4. convert the document to xml string.

or
you can make use of xslt files. we have built-in services which takes the document and xslt file as input and returns the xml file.

As xml is just a string variable in webMethods, you can use string based operations like concat, append etc to manipulate the XML content at run time.

Hi,

modifying the xml string directly can teadious depending on the complexity of the message.
On the other side the mentioned string operations are very cost-intensive regarding their runtime.

I prefer one of the approaches Naga has suggested.

Regards,
Holger

Hello.

thanks for your replies.

will it be possible to use e.g. service “pub.xml:xmlNodeToDocument” and still preserve all document type elements
although they are not present in the source xml ? Normally they are elimnated from pipeline if empty.

I ask why i need the (even) empty values (here CONTROLLER) for calling webservice later on.

Can this be done by XSLT ? Is there any sample for doing so ?

Please find screenshot attached. :slight_smile:

BR,
Sebastian

Hi Sebastian,

looks like a defect in your Designer.

Can you provide us the version of Designer and the applied ESB-Fix (for the ServiceDevelopment Part)?

The referenced DocTypes (DocType names) are not part of the xml message itself but of the flow service implementation. So they should not get lost.
More likely this is just a displaying issue.

Regards,
Holger

I guess, there is no feature to generate these null tags using xmlNodeToDocument service.
However, this can be done, using the documentToXMLString service by setting generateRequiredTags to true.

And I guess, this will generate only the null fields if they are mandatory. But it won’t generate if they are optional.
and for optional fields, i believe, there won’t be any issue in Webservice invocations with this approach, as they are anyway optional fields.

so, convert the run time xmlString (won’t consists of all nodes) ->xmlNode->xmlDocument (consists of all nodes at design time, won’t present at run time ) ->xmlString (with above option, generates missing tags)

Even in java using parsers we can do so, please give a try.

Thanks,