Skip to content

Commit

Permalink
fix: vcsim: swap order of xsi type attribute
Browse files Browse the repository at this point in the history
PropertyCollector responses always included the 'xsi:type' attribute.
When a property type is ManagedObjectReference, there are 2 'type' attributes in the response, for example:

 <val xsi:type="ManagedObjectReference" type="LicenseAssignmentManager">LicenseAssignmentManager</val>

Some clients (Java) have problems with this. Changing the order to be the same as real vCenter to workaround:

 <val type="LicenseAssignmentManager" xsi:type="ManagedObjectReference">LicenseAssignmentManager</val>

Fixes #2114

Signed-off-by: Doug MacEachern <[email protected]>
  • Loading branch information
dougm committed Dec 6, 2024
1 parent 211be90 commit 675534a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions vim25/xml/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
}
Expand Down

0 comments on commit 675534a

Please sign in to comment.