nube soap::mapping::object question

Discussion in 'Ruby' started by bradrover, Jun 15, 2007.

  1. bradrover

    bradrover Guest

    I've been banging my head against the wall on this problem. I have a
    soap::mapping::eek:bject result from a web service call, and all is well
    except there are some XML elements in the response that are empty.
    When I output these values in a UI (puts, etc) the value for those
    elements always says something like #<soap::mapping::eek:bject::0x...>

    How can I test this value to see if its an empty element before I
    output it ? Is there a more elegant way to handle this than doing a
    check for this particular string literal ? I didn't see any methods on
    soap::mapping::eek:bject to determine if it has a text element or not.
     
    bradrover, Jun 15, 2007
    #1
    1. Advertising

  2. -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    Hi,

    bradrover wrote:
    > I've been banging my head against the wall on this problem. I have a
    > soap::mapping::eek:bject result from a web service call, and all is well
    > except there are some XML elements in the response that are empty.
    > When I output these values in a UI (puts, etc) the value for those
    > elements always says something like #<soap::mapping::eek:bject::0x...>


    Can you show me a sample response XML? I don't understand 'empty element'.

    irb(main):001:0> require 'xsd/mapping'
    => true
    irb(main):002:0> xml = <<__XML__
    irb(main):003:0" <foo>
    irb(main):004:0" <bar/>
    irb(main):005:0" <baz>qux</baz>
    irb(main):006:0" </foo>
    irb(main):007:0" __XML__
    => "<foo>\n <bar/>\n <baz>qux</baz>\n</foo>\n"
    irb(main):008:0> obj = XSD::Mapping.xml2obj(xml)
    => #<SOAP::Mapping::Object:0x..fdbd9b682 {}bar="" {}baz="qux">
    irb(main):009:0> obj.bar
    => ""
    irb(main):010:0> obj.baz
    => "qux"

    Is the above 'bar' empty? Do you mean an ommitted element?

    > output it ? Is there a more elegant way to handle this than doing a
    > check for this particular string literal ? I didn't see any methods on
    > soap::mapping::eek:bject to determine if it has a text element or not.


    Sometimes generating stub files with wsdl2ruby.rb is of help. Generated
    Driver can use type information while parsing XML to help extracting
    values from it.

    Regards,
    // NaHi

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.2.1 (Cygwin)

    iQEVAwUBRnOt4h9L2jg5EEGlAQIJ8QgAnqBqN/Q0ijMA8fGhe74JM5VTtRY9q+3+
    PUNimT2tLhX9BAYb++Uw93+klTgHI/itziJNj72k9uO5+WSBcYqjIkKgnRd4xOyF
    W2MosTBH0X4LvFmijkvIwN89kGflQkoghS3IgX7Fl8trf0LM8clrhZzeFz/JtGRf
    AX/+xRaphu19Lj6BZ9vP7FSefr89RsoXHutKbjL7dlK16Ds9zucYuX/iFXbv/X3Z
    6ypbCuYZxU1c/1AF7Dlq6Jhzy/Dda0JTzNYCdeFCtgxzYBF0TIgyCV2TlbMywCoe
    xN+z12qFFR47EB77vLGXkAvXuVrQKjPdkzBBQahte/3G1bkivrz3lg==
    =92kR
    -----END PGP SIGNATURE-----
     
    NAKAMURA, Hiroshi, Jun 16, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bagman
    Replies:
    7
    Views:
    538
  2. Dan Fitzpatrick
    Replies:
    1
    Views:
    353
    NAKAMURA, Hiroshi
    Jul 16, 2005
  3. Mason Brown
    Replies:
    1
    Views:
    379
  4. Bill Man

    Ruby Nube

    Bill Man, Jun 15, 2007, in forum: Ruby
    Replies:
    4
    Views:
    124
    vasudevram
    Jun 15, 2007
  5. Ruby Rookie

    accessing SOAP::Mapping::Object

    Ruby Rookie, Aug 13, 2007, in forum: Ruby
    Replies:
    2
    Views:
    250
    Ruby Rookie
    Aug 14, 2007
Loading...

Share This Page