Have you tried using the parameter "documentTypeName" to provide the fully qualified document type name for the service pub.xml:documentToXMLString? The documentation "IntegrationServer Build-In Service Reference" states:
documentTypeName String Optional Fully qualified name of the document type that describes the structure and format of the output
document (for example, examples.rtd:exampleRecord1). You can use this
parameter to ensure that the output includes elements that might not
be present in document at run time, or to describe the order in which
elements are to appear in the resulting XML String.
EDIT: adding example, using wM 9.7
E.g. I have a xml string like:
<?xml version="1.0"?>
<inputdoc>
<field5>afds</field5>
<field1>asdf</field1>
<field3>asdf</field3>
<field2>asdf</field2>
</inputdoc>
I have an IS doc type with fields field1, field2, field3 and field5 in this order. I have a service where have one input named xmlstring, which contains the above xml string. I call the following services:
- pub.xml:xmlStringToXMLNode: mapping my xml string to xmldata input-field
- pub.xml:xmlNodeToDocument: converting my node to a document without using "documentTypeName" input-field
- pub.xml:documentToXMLString: converting my document instance to a XML string using the input-field "documentTypeName" with my defined IS doc type.
This results in the following XML string:
<?xml version="1.0"?>
<field1>asdf</field1>
<field2>asdf</field2>
<field3>asdf</field3>
<field5>afds</field5>
As you can see the order has changed in the correct way.
Greetings
Henning