Consume SOAP Service from RhoMobile (iPhone, Android, WM and so on) apps

December 26, 2011

We wanted to consume simple SOAP based web services from the iPhone, Android applications using RhoMobile framework. We dont want to use Savon as it got too much dependency to become rhodes-ruby extension.
Just thought lets write the raw soap client without using SOAP gems. Rhodes already support net-http and rexml(rhoxml) for such tasks.

The sample source code can be found at which basically consume the SOAP services from

The basic steps involve on the controller side involves:

  1. Initialize the http object with soap service url
          http ='', 80)
          path = '/webservices/tempconvert.asmx' 
  2. Create the SOAP Request envelope
    data = <<-EOF
    <?xml version="1.0" encoding="UTF-8"?>
      <CelsiusToFahrenheit xmlns="">
  3. Set Headers if required
    headers = {
            'Content-Type' => 'text/xml',
            'Host' => ''
  4. Make the http request and then process the result data
    resp, data =, data, headers)
    puts data
  5. Sample SOAP Response
    <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="" xmlns:xsi="" xmlns:xsd=""><soap:Body><CelsiusToFahrenheitResponse xmlns=""><CelsiusToFahrenheitResult>89.6</CelsiusToFahrenheitResult></CelsiusToFahrenheitResponse></soap:Body></soap:Envelope>

If you want you can also the process the SOAP Response string using XML parsers like rhoxml.

xmldoc =
xmldoc.elements.each("soap:Envelope/soap:Body/CelsiusToFahrenheitResponse/CelsiusToFahrenheitResult") { |e| puts e.text

If you want to see how we can use savon as rhodes-ruby-extensions, please leave us a comment so that we can share our code on Github.

5 Comments. Leave new


I’m trying to use savon with RhoMobile, can you share your code?

Thank you in advance,

Jose Marques
March 29, 2012 3:24 AM

I am trying to use savon with rhomobile, and getting into a lot of trouble with its dependencies….

If you got a sample running, can you post it?


Balaji D Loganathan
April 6, 2012 12:16 PM

Sorry we dont have a sample for it. We opt for custom http post than going through the gem dependencies pain of savon.

I am trying to consume a soap webservice in a rhomobile app, so this blog looked perfect.

However I have added to the extensions in the build file but I must be missing something (very new to rhodes/ruby)

When I try to create the http object on 1. I get an error.

I’m getting ‘source not found’ within a tab labelled ‘extensions/net-http/net/http’

Any help appreciated – thanks.

Vaibhav SHarma
October 18, 2012 3:34 PM

I am trying to consume SOAP service likewise and it is working good in rho simulator but when I bulid it on wondows mobile CE 6.5, application closes as soon as I click on my button to call that action, I have used my SOAP service almost the same way as it shown above
please help

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: