Hi, all,
I am the beginner to use suds.
Now I encoutnter one problem when using suds to send operation request to VMWare VSphere Server. May I get your help on this issue.
I couldnt' use suds to construct the argument to be used by VMWare ESX functton "*RetrieveServiceContent". * ** The parameter xml should be "<_this type="ServiceInstance">ServiceInstance</_this>".
How can I use suds to construct this kind of function parameter?
I pasted my script, error output, wsdl. Here
~~~~~~~~~~~~~~~~~~~~-Python Script begin------------------------------------------------------------- url = 'https://10.204.211.1/sdk/vimService.wsdl' #start(url) client = Client(url) #print client client.set_options(location='https://10.204.211.1/sdk') mor=client.factory.create('ns0:ManagedObjectReference') mor._type='ServiceInstance' _sjc=client.service.RetrieveServiceContent(mor) print _sjc ~~~~~~~~~~~~~~~~~~~~Python script end~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~Error Msg begin~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (ManagedObjectReference){ _type = "" } DEBUG:suds.client:sending to (https://10.204.211.1/sdk) message: <SOAP-ENV:Envelope xmlns:ns0="urn:vim25" xmlns:xsi=" http://www.w3.org/2001/XMLSc hema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/%22%3E SOAP-ENV:Header/ SOAP-ENV:Body ns0:RetrieveServiceContent <ns0:_this xsi:type="ServiceInstance"/> </ns0:RetrieveServiceContent> </SOAP-ENV:Body> </SOAP-ENV:Envelope> DEBUG:suds.client:headers = {'SOAPAction': u'"urn:vim25/4.0"', 'Content-Type': ' text/xml'} ERROR:suds.client:<?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:ns0="urn:vim25" xmlns:xsi=" http://www.w3.org/2001/XMLSc hema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/%22%3E SOAP-ENV:Header/ SOAP-ENV:Body ns0:RetrieveServiceContent <ns0:_this xsi:type="ServiceInstance"/> </ns0:RetrieveServiceContent> </SOAP-ENV:Body> </SOAP-ENV:Envelope> DEBUG:suds.client:http failed: <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance%22%3E soapenv:Body soapenv:Fault<faultcode>ServerFaultCode</faultcode><faultstring>type</faultstr ing><detail><InvalidRequestFault xmlns="urn:vim25" xsi:type="InvalidRequest"></I nvalidRequestFault></detail></soapenv:Fault> </soapenv:Body> </soapenv:Envelope> Traceback (most recent call last): File "C:\Project\wsdl\test.py", line 42, in <module> _sjc=client.service.RetrieveServiceContent(mor) File "C:\Python26\lib\site-packages\suds-0.3.8-py2.6.egg\suds\client.py", line 537, in __call__ return client.invoke(args, kwargs) File "C:\Python26\lib\site-packages\suds-0.3.8-py2.6.egg\suds\client.py", line 597, in invoke result = self.send(msg) File "C:\Python26\lib\site-packages\suds-0.3.8-py2.6.egg\suds\client.py", line 632, in send result = self.failed(binding, e) File "C:\Python26\lib\site-packages\suds-0.3.8-py2.6.egg\suds\client.py", line 683, in failed r, p = binding.get_fault(reply) File "C:\Python26\lib\site-packages\suds-0.3.8-py2.6.egg\suds\bindings\binding .py", line 235, in get_fault raise WebFault(p, faultroot) suds.WebFault: Server raised fault: 'type' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---------------------------------------------------------------------------------------
----------------------------------------WSDL - ManagedObjectReference------------------------------------- *-* https://10.204.211.1/sdk/vim.wsdl# <complexType name="* ManagedObjectReference*"> *-* https://10.204.211.1/sdk/vim.wsdl# <simpleContent> *-* https://10.204.211.1/sdk/vim.wsdl# <extension base="*xsd:string*"> * * <attribute name="*type*" type="*xsd:string*" /> * * </extension> * * </simpleContent> * * </complexType>
----------------------------------------------------------------------------------------------------------------------------
------------------------------------- WSDL -Function * RetrieveServiceContent------------------------* *-* https://10.204.211.1/sdk/vim.wsdl# <complexType name="* RetrieveServiceContentRequestType*"> *-* https://10.204.211.1/sdk/vim.wsdl# <sequence> * * <element name="*_this*" type="*vim25:ManagedObjectReference*" /> * * </sequence> * * </complexType> * * <element name="*RetrieveServiceContent*" type="* vim25:RetrieveServiceContentRequestType*" /> *-* https://10.204.211.1/sdk/vim.wsdl# <element name="* RetrieveServiceContentResponse*"> *-* https://10.204.211.1/sdk/vim.wsdl# <complexType> *-* https://10.204.211.1/sdk/vim.wsdl# <sequence> * * <element name="*returnval*" type="*vim25:ServiceContent*" /> * * </sequence> * * </complexType> * * </element> -------------------------------------------------------------------------------------------------------------