From: emcconne Date: 2006-08-02T01:05:05+09:00 Subject: wsdl2ruby and SOAP problems I am new to Ruby and am evaluating it for a project that would replace and extend existing Perl code. I am using wsdl2ruby to generate a client stub with associated classes for a web service. Most of the basic calls more fine but the more complex method calls that take parameter "anyType" do not work so well. It appears that the type is not getting set in the SOAP message generated by ruby. However, the perl code does allow me to set the type (manually by calling SOAP::Data -> type using SOAP::Lite). Below is the relevant code and generated messages: -----RELEVANT WSDL SECTION---- :document, :request_use => :literal, :response_style => :document, :response_use => :literal } ] ] def initialize(endpoint_url = nil) endpoint_url ||= DefaultEndpointUrl super(endpoint_url, nil) self.mapping_registry = MappingRegistry init_methods end private def init_methods Methods.each do |definitions| opt = definitions.last if opt[:request_style] == :document add_document_operation(*definitions) else add_rpc_operation(*definitions) qname = definitions[0] name = definitions[2] if qname.name != name and qname.name.capitalize == name.capitalize ::SOAP::Mapping.define_singleton_method(self, qname.name) do |*arg| __send__(name, *arg) end end end end end end -----FROM CLIENT----- require 'vmaDriver.rb' endpoint_url = ARGV.shift $KCODE = 'UTF8' obj = VmaPortType.new(endpoint_url) obj.generate_explicit_type = true # run ruby with -d to see SOAP widumps. obj.wiredump_dev = STDERR parameter=nil vmlogin=Login.new("emcconne", "oh,bother") puts obj.login(vmlogin) vmcenter=ResolvePath.new("/vcenter/Testdrive_Farm") vmdomain=obj.resolvePath(vmcenter).returnval vmpath=ResolvePath.new("/host/192.168.0.2") vmhost=obj.resolvePath(vmpath).returnval vmcpuinfo=VirtualCPUInfo.new(2,"") vmmeminfo=VirtualMemoryInfo.new(512,"") vmhardware=VirtualHardware.new(vmcpuinfo,vmmeminfo,"","",[],[],[]) vmspec=VirtualMachineSpec.new(vmhost,"linux","",vmhardware) vmcreate=Create.new(vmdomain,"rubyvm","VirtualMachine",vmspec) puts obj.create(vmcreate) ----- GENERATED MESSAGE ----- vma-domain-00000000001 rubyvm VirtualMachine vma-host-00000000002 linux 2 512 -------WORKING PERL MESSAGE ------ vma-domain-00000000001 perlvm VirtualMachine vma-host-00000000002 Linux 1 256