From f08496edda1631f284588096b695406cef96c4ae Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Thu, 5 Dec 2024 09:25:35 -0800 Subject: [PATCH] fix: vcsim: swap order of xsi type attribute PropertyCollector responses always included the 'xsi:type' attribute. When a property type is ManagedObjectReference, there are 2 'type' attributes in the response, for example: LicenseAssignmentManager Some clients (Java) have problems with this. Changing the order to be the same as real vCenter to workaround: LicenseAssignmentManager Fixes #2114 Signed-off-by: Doug MacEachern --- vim25/xml/marshal.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vim25/xml/marshal.go b/vim25/xml/marshal.go index c0c0a588b..2efdb7a46 100644 --- a/vim25/xml/marshal.go +++ b/vim25/xml/marshal.go @@ -497,11 +497,6 @@ func (p *printer) marshalValue(val reflect.Value, finfo *fieldInfo, startTemplat start.Name.Local = name } - // Add type attribute if necessary - if finfo != nil && finfo.flags&fTypeAttr != 0 { - start.Attr = append(start.Attr, Attr{xmlSchemaInstance, typeToString(typ)}) - } - // Attributes for i := range tinfo.fields { finfo := &tinfo.fields[i] @@ -524,6 +519,11 @@ func (p *printer) marshalValue(val reflect.Value, finfo *fieldInfo, startTemplat } } + // Add type attribute if necessary + if finfo != nil && finfo.flags&fTypeAttr != 0 { + start.Attr = append(start.Attr, Attr{xmlSchemaInstance, typeToString(typ)}) + } + if err := p.writeStart(&start); err != nil { return err }