From: Mark Slater Date: 2007-01-03T17:43:09+09:00 Subject: SOAP: detecting nil element in the response I'm still getting used to Ruby, so there could be a very easy and obvious answer to this one. Essentially, the server sends back nil elements, which Ruby translates into SOAP::Mapping::Object instances. But how do I determine when those SOAP::Mapping::Object instances represent nil elements? Here are the details. I'm calling a soap method to get profile information about a user in the system I'm writing. The soap that comes back looks like this: This is stuff about me. Last First 0 Dr. Esq previous_name_1 previous_name_2 The WSDL (auto generated by XFire) for this particular type is: You'll notice that the otherNames element in the response is nil and that its typed as a string in the WSDL. Users are not required to enter any of this data, so having nil elements in the response is valid semantically. In trying to figure out how Ruby SOAP clients work, I'm doing the following when I get the results back: ... results = driver.getUserInformation( :in0 => user ) puts '----- result data -----' puts "name: #{results.out.namePrefix} #{results.out.firstName} # {results.out.otherNames} #{results.out.familyName}, # {results.out.nameSuffix}" puts "gender: #{results.out.gender}" puts "about text: #{results.out.aboutText}" puts "first name type = #{results.out.firstName.class}" puts "other names type = #{results.out.otherNames.class}" puts "previous names type = #{results.out.previousNames.class}" The output of that code gives me: ----- results ----- # {http:// core.whisper.ucsc.edu}previousNames=#>> ----- result data ----- name: Dr. First # Last, Esq gender: "0" about text: "This is stuff about me." first name type = String other names type = SOAP::Mapping::Object previous names type = SOAP::Mapping::Object Obviously if the element is assigned to an object, I can't just test to see if its nil; I've also tried comparing it to an empty string. Is there any way to do detect a nil element in the SOAP response? Thanks, Mark