Welcome to the "trac"-ing site of soap4r!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

Ticket #306 (reopened defect)

Opened 2 years ago

Last modified 11 months ago

String subclass is generated wrongly from simpleContent

Reported by: anonymous Assigned to: nahi
Priority: high Milestone: 1.5.6
Component: wsdl4r Version: 1.5
Keywords: wsdl2ruby attributes managedobjectreference vim sdk Cc: soap4r@ukeer.de

Description (Last modified by nahi)

iam pretty new to soap4r, so i hope this isnt dupe, false, or iam lacking information :-)

wsdl:
         <complexType name="ManagedObjectReference">
            <simpleContent>
               <extension base="xsd:string">
                  <attribute name="type" type="xsd:string"/>
               </extension>
            </simpleContent>
         </complexType>

gets generated into:

class ManagedObjectReference? < String end

which seems wrong, since it doesnt account for the attribute?

Change History

04/29/07 21:23:50 changed by nahi

  • milestone changed from undefined to 1.5.6.

04/29/07 23:07:00 changed by nahi

  • component changed from soap4r to wsdl4r.
  • summary changed from simple to String subclass is generated wrongly from simpleContent.

05/05/07 00:26:08 changed by nahi

  • priority changed from normal to high.

05/13/07 19:38:26 changed by nahi

  • description changed.

05/13/07 20:52:39 changed by nahi

  • status changed from new to closed.
  • resolution set to duplicate.

-> #176

11/23/07 06:17:31 changed by user

  • keywords set to wsdl2ruby attributes managedobjectreference vim sdk.
  • status changed from closed to reopened.
  • resolution deleted.

I HAVE REOPENED THIS TICKET BECAUSE THE PROBLEM STILL EXISTS IN 1.5.8! You closed both tickets as duplicates (of each other?) but no resolution seems to have come out of it. Here is more information. please feel free to contact me at l0r3zz "at" gmail "point" com....

Hi again, I had no luck with the last request let me try a different approach. I'm working on a Ruby SDK for VMware's Virtual Infrastructure. I've used wsdl2ruby to process the vim.wsdl file and I have a "working" library that I've written some code to even do a cold migration. But there are problems...

when I execute method calls I often have to have an object of type ManagedObjectReference? which is fine, I can initialize one pretty easy such as...

# Set up to do a search by creating a SearchIndex? Managed Object morSearchIndex = ManagedObjectReference?.new(_sic.returnval.searchIndex) morSearchIndex.xmlattr_type = "SearchIndex?"

Now I perform a query... # Get Managed Object References for PathToVm?, PathToDatacenter? and PathToComputeResources?

vmp = _service.findByInventoryPath(FindByInventoryPath?.new(morSearchIndex,"/ MonkeyCenter?/vm/#{vmname}"))

which returns this across the wire...

= Response

HTTP/1.1 200 OK Date: Thu, 25 Oct 2007 21:35:02 GMT Cache-Control: no-cache Content-Type: text/xml; charset=utf-8 Content-Length: 459

<?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">

<soapenv:Body> <FindByInventoryPathResponse? xmlns="urn:vim2">

<returnval type="VirtualMachine?">vm-1679</returnval>

</FindByInventoryPathResponse> </soapenv:Body> </soapenv:Envelope>

The call... vmMoRef = ManagedObjectReference?.new(vmp.returnval) Creates a ManagedObjectReference? object BUT it doesn't set the xattr_type (in this case returnval type="Virtual Machine" ) This is a problem as subsequent code relies on the correct value of this field to be set. I get the code to run by inspecting the wire dump and setting it by hand :(

vmMoRef.xmlattr_type = "VirtualMachine?"

which is definitely NOT the way to make this work.

Here is the definition from the vim.wsdl file which defines the SDK API:

<complexType name="ManagedObjectReference?">

<simpleContent>

<extension base="xsd:string">

<attribute name="type" type="xsd:string"/>

</extension>

</simpleContent>

</complexType>

Here is what wsdl2ruby generates:

# {urn:vim2}ManagedObjectReference # xmlattr_type - SOAP::SOAPString class ManagedObjectReference? < ::String

AttrType? = XSD::QName.new(nil, "type")

def xmlattr

@xmlattr = {}

end

def xmlattr_type

xmlattr[AttrType?]

end

def xmlattr_type=(value)

xmlattr[AttrType?] = value

end

def initialize(*arg)

super @xmlattr = {}

end

end

Here is the .wsdl for the FindByInventoryPath? request and response... <element name="FindByInventoryPath?">

<complexType>

<sequence>

<element name="_this" type="vim2:ManagedObjectReference" /> <element name="inventoryPath" type="xsd:string" />

</sequence>

</complexType>

</element> <element name="FindByInventoryPathResponse?">

<complexType>

<sequence>

<element name="returnval" type="vim2:ManagedObjectReference" minOccurs="0" />

</sequence>

</complexType>

</element>

Here is what wsdl2ruby generates for FindByInventoryPath?... [ "",

"findByInventoryPath", [ ["in", "parameters", ["::SOAP::SOAPElement", "urn:vim2", "FindByInventoryPath?"], true],

["out", "parameters", ["::SOAP::SOAPElement", "urn:vim2", "FindByInventoryPathResponse?"], true] ],

{ :request_style => :document, :request_use => :literal,

:response_style => :document, :response_use => :literal }

],

# {urn:vim2}FindByInventoryPath # mthis - ManagedObjectReference? # inventoryPath - SOAP::SOAPString class FindByInventoryPath?

attr_accessor :inventoryPath

def mthis

@vthis

end

def mthis=(value)

@vthis = value

end

def initialize(vthis = nil, inventoryPath = nil)

@vthis = vthis @inventoryPath = inventoryPath

end

end

# {urn:vim2}FindByInventoryPathResponse class FindByInventoryPathResponse?

@@schema_type = "FindByInventoryPathResponse?" @@schema_ns = "urn:vim2" @@schema_qualified = "true" @@schema_element = [["returnval", "ManagedObjectReference?"]]

attr_accessor :returnval

def initialize(returnval = nil)

@returnval = returnval

end

end

What I need is the value of the "type" attribute to be set on the client side for ManagedObjectReference?, right now (in this case) the content for the element with the atribute name=returnval is passed back to the client and is available to the Ruby call, but the value of the "type" attribute is not, and I need this info to be set for the toolkit to be viable, Can someone show me what I'm doing wrong OR how to fix this in the vim.wsdl file OR give me pointers on how to fix it in wsdl2ruby OR fix it in wsdl2ruby ?

Thanks for reading!