Forum: Ruby soap4r attributes vs elements

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Roy Britten (Guest)
on 2007-02-26 22:37
(Received via mailing list)
Hi list,

soap4r is great when it comes to creating requests consisting of
elements

  require 'soap/wsdlDriver'
  driver = SOAP::WSDLDriverFactory.new(wsdlURL).create_rpc_driver
  driver.getSomething(:foo=>"bar")

I have a third-party web service utilising attributes of the request
object, rather than nested elements.

soap4r is generating this:

  <name>
  </name>

What I'm after is this:

  <name foo="bar" />

the web service doesn't accept this:

  <name>
    <foo>bar</foo>
  </name>

Is there any means of achieving this with soap4r?

Thanks,
Roy.
NAKAMURA, Hiroshi (Guest)
on 2007-06-06 18:03
(Received via mailing list)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

Sorry for the late response.

Roy Britten wrote:
> I have a third-party web service utilising attributes of the request
> object, rather than nested elements.

> What I'm after is this:
>
>  <name foo="bar" />

> Is there any means of achieving this with soap4r?

You need to construct SOAP element object.

  ele = SOAP::SOAPElement.new("name")
  ele.extraattr["foo"] = "bar"
  driver.invoke(ele)

Regards,
// NaHi

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

iQEVAwUBRma+ax9L2jg5EEGlAQIzKQgAv9Ffq4Ny+zpZ0kxfT/2cCpKJWxFY4msd
QxEahJ5dWDtRYUkIoUGu7sZ1LwDAZ8NyznkjctH14wjih42YDf5vOKyzC6fr+jak
KKfXFMGmSGlAHD9zfsmIixdIqx8F2eh8E0zwMSv/JUgECw9/5/f9ZPPeEDT5No7B
jjmgmK8diVS+jzOix5dyZSsIFPAprxS06VOQrD5qs91ijQhoWx63odml0CamGiWv
Xf0zex3VTBybQ6xufpeNaDAYRX9EPFNHjJBEYYLc4plPoWGHLC2soUdwUSyL5fIg
LHzlwP9V28Qnnkjk1VquryOsOP01Sn6x/jXiK61MZEPG1DTJYX4OAA==
=kept
-----END PGP SIGNATURE-----
Roy Britten (Guest)
on 2007-08-02 06:34
(Received via mailing list)
On 07/06/07, NAKAMURA, Hiroshi <removed_email_address@domain.invalid> wrote:
> You need to construct SOAP element object.
>
>   ele = SOAP::SOAPElement.new("name")
>   ele.extraattr["foo"] = "bar"
>   driver.invoke(ele)

Many thanks. That'll make life easier.

Cheers,
Roy.
This topic is locked and can not be replied to.