converting xsd:anytype to xsd:string

67 views
Skip to first unread message

Kiran Madabhushi

unread,
Apr 3, 2013, 1:26:07 PM4/3/13
to psp...@googlegroups.com
Hi
Some of the objects in vsphere sdk defined the attributes as xsd:anytype and I need to convert them to xsd:string

How do I do this one?

E.g is the while using the OptionManager (setting)

Thanks
Kiran

Jonathan Kinred

unread,
Apr 4, 2013, 11:03:58 PM4/4/13
to psp...@googlegroups.com
Hi Kiran,

Can you post some example code?

Jonathan

Kiran Madabhushi

unread,
Apr 8, 2013, 2:13:16 PM4/8/13
to psp...@googlegroups.com
Jonathan

Once you connect to the server, get the option manager

client = Client(ip,user,password)
om = client.si.content.setting

om.QueryOptions(name='VirtualCenter.FQDN')

returns

[(OptionValue){
   key = "VirtualCenter.FQDN"
   value = "localhost"
 }]

I want to change this, so I create the OptionValue spec

spec = client.create('OptionValue')
spec.key = "VirtualCenter.FQDN"
spec.value = "172.0.0.1"

om.UpdateOptions(spec)

The problem is the value is of "any type" and to force that to string the xml looks like this

<value type='xsd:string'>172.0.0.1'</value>

If i use the spec.value as in the example then 'xsd:string' is not set and vcenter throws an error

This is true with all messages where th type is of "any type"

Hope I am clear here

Kiran
Reply all
Reply to author
Forward
0 new messages