tags:

views:

63

answers:

2

I am using a gem which uses soap/wsdlDriver.

When I post I get back a SOAP response and am unable to easily parse it.

This is the response I get back:

#<SOAP::Mapping::Object:0x159e95faf098 {}id="27b907f8-da51-f611-ab02-4c5f88a8ec8
8" {}error=#<SOAP::Mapping::Object:0x159e95fae33c {}number="0" {}name="No Error"
 {}description="No Error">>

I need to get the entire value in the id="xxxx"

This is what on get on heroku (note: it works locally). This comes from testing various variations of response.id (where response.inspect is what created the output above)

f" {}error=#> response[id] /disk1/home/slugs/220752_47a08bb_10e7/mnt/app/controllers/sugarcrm_controller.rb :77: warning: Object#id will be deprecated; use Object#object_id nil response.id: /disk1/home/slugs/220752_47a08bb_10e7/mnt/app/controllers/sugarcrm_controller.rb :79: warning: Object#id will be deprecated; use Object#object_id 23891500658740 /disk1/home/slugs/220752_47a08bb_10e7/mnt/app/controllers/sugarcrm_controller.rb :80: warning: Object#id will be deprecated; use Object#object_id this is the contact_id: 23891500658740 events:

A: 

I don't know how to do this with ruby, but may be like this code in javascript.

var t = "<SOAP message........>";
var id = t.replace(/.*id=\"(.*?)\".*/, "$1");

Regex details:

.*id=\"(.*?)\".*

.* = anything, 0 or N times.
(.*?) = anything, 0 or N times, stopping at first match.
$1 = first group, the content inside ().

So, everthing will be replaced by id content.

Topera
A: 

Ok, I'm 95% sure that is the output of SOAP::Mapping::Object#inspect and not the actual response. And from that class it looks you use the [] method to pull out attributes.

So if I am reading that right, then it looks like you might want:

response_id = response_object['id']

Though each attribute being prefaced with {} seems pretty odd. So if that is actually part of the attribute name, you may need:

response_id = response_object['{}id']

But that seems pretty strange, and may indicate that the SOAP library you are using is not parsing the response properly.

Disclaimer: I've never used this lib before, and posted this from just perusing the docs... This may or may not be very accurate in the ways using this class is described.

Squeegy
Yes, that's what I was hoping...but what I get is a different string when I do it. It works locally, but when I heroku, instead of the alpha-numeric string, all I get is a string of numbers, which isn't correct...thoughts?
Angela
Here is the output I get on heroku versus local:Object#id will be deprecated; use Object#object_id Perhaps that will shed some light?
Angela
It might be a different version of ruby or the SOAP lib causing it to behave in 2 different ways.
Squeegy
Hi, how could I check -- I believe we're both on ruby 1.8.7...ah, wait, the other app is still on the old one...ah, yeah, that's it
Angela
I just checked it on the new heroku stack -- still getting the error :(
Angela