Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
adding soap element attributes
Andrew Tongen
10/27/2006 4:43:00 PM
Hi,
I have a question that I hope will be simple for someone to answer.
I am using soap4r to write a simple library to consume web services from
an application. The application does not include a WSDL document, so I
have to write everything by hand.
The application requires attributes in certain elements of the soap
request, and I am having a little trouble figuring out how to do this.
So far, a portion of my test code looks like this:
driver = SOAP::RPC::Driver.new(endpoint, 'urn:namespace')
driver.add_method_as('get_account', 'GetAccountRequest', 'account')
get_account = driver.get_account('user@example.com')
which produces this:
<n2:GetAccountRequest xmlns:n2="urn:namespace"
env:encodingStyle="
http://schemas.xmlsoap.org/soap/encoding/...
<account xsi:type="xsd:string">user@example.com</account>
</n2:GetAccountRequest>
but I need the soap request to look like this:
<n2:GetAccountRequest xmlns:n2="urn:namespace"
env:encodingStyle="
http://schemas.xmlsoap.org/soap/encoding/...
<account by="name" xsi:type="xsd:string">user@example.com</account>
</n2:GetAccountRequest>
with the by="name" attribute in the account element.
I've been experimenting with SOAP::Mapping::Registry to achieve this,
but I am not sure how it would be done, or even if this is the correct
approach to take. If anyone can offer any assistance, it would be
appreciated.
Thanks,
Andrew
--
Posted via
http://www.ruby-...
.
1 Answer
Andrew Tongen
10/31/2006 4:36:00 PM
0
Thanks Hiroshi, that got me started. Soap4r is great, I just wish this
app had a WSDL!
I may consider writing a WSDL for this application, but for now I only
need a subset of fucntionality. The request objects are all pretty
simple, but I am having trouble accessing data from the response
objects.
After calling:
get_account = driver.get_account('user@example.com')
The raw XML response for this command looks something like this:
<GetAccountResponse xmlns:ns0="urn:namespace">
<account name="user@example.com"
id="770316d9-qwe4-38eu-s84h-2dfe3c6cc874">
<a n="key1">value1</a>
<a n="key2">value2</a>
<a n="key3">value3</a>
...
</account>
</GetAccountResponse>
I need to access the key/value pairs in the a attributes, but
get_account.account.a simply returns an array of [value1, value2,
value3, ...] and seems to ignore the attributes. Many response objects
for this app take this form, so it would be nice to be able to create a
hash, or ruby object dynamically based on the key/values.
Can I access the raw response XML somehow, or is there a better way to
do this?
The app I am using is Zimbra, in case anyone has any experience or
advice for use with Soap4r.
Thanks again,
Andrew
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
adding soap element attributes
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password