4

Untill now I used soap4r as my SOAP-client with Ruby 1.8.x, but now I am moving on to Ruby 1.9.x. Unfortunately soap4r doesn't work with Ruby 1.9.x I just get the "invalid multibyte escape" which seems not solvable, mostly because the soap4r gem wasn't updated since 2007, so I assume the project is dead.

I had a look at handsoap but there I have to map all the stuff by hand it will take several days to do that by hand, it is a big API.

Is there some other soap client which automaticly maps all the soap-xml stuff to ruby-objects (link soap4r did) and vise versa?

Jeena
  • 2,172
  • 3
  • 27
  • 46

2 Answers2

5

Savon abstracts the XML part into a Ruby Hash. Have a look: http://github.com/rubiii/savon

rubiii
  • 1,926
  • 2
  • 12
  • 8
  • I never understood that, but now I see how it works. Anywas there is still one problem, it looses all XML attributes like my content. But I can take the XML and parse it with XmlSimple.xml_in(response.to_xml, { 'ForceArray' => false }). Thanks for pointing me in the right direction! – Jeena Feb 07 '10 at 22:40
  • Unfortunately you're right. Savon uses the Crack gem by John Nunemacker to translate the XML to a Hash. The problem with attributes is a known bug in the Crack library. – rubiii Mar 05 '11 at 13:03
3

If that is the issue with handsoap then you can use the hashie gem with handsoap. Hashie converts the xml elements to instance method calls, if that helps.

Soap4R is a pain but I like it for one reason, that is the standalone soap server that it provides. It makes testing external soap services so much easier by building your own soap server in a snap that just mocks the response so that, one you don't have to make request to external soap server for integration tests and second it doesn't leaves the code related with soap client untested.

nas
  • 3,676
  • 19
  • 19
  • I like using the vcr gem, so that once I have specs which cover calls to the external soap server, those results are cached in cassettes. So then I can run my specs even without any network access and without the need to have a local soap server either. Using handsoap configured to use net http for its calls, vcr automatically intercepts its calls. – Benissimo May 08 '15 at 09:46