# Weird behaviour of a Web Service

**URL:** <https://www.ruby-forum.com/t/weird-behaviour-of-a-web-service/159956>\
**Category:** Rails\
**Created:** [February 10, 2009, 12:29pm UTC](https://www.ruby-forum.com/t/weird-behaviour-of-a-web-service/159956 "2009-02-10T12:29:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rey9999](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8e8cbc/32.png) [@Rey9999](https://www.ruby-forum.com/u/Rey9999)\
**Post date:** [February 10, 2009, 12:29pm UTC](https://www.ruby-forum.com/t/weird-behaviour-of-a-web-service/159956/1 "2009-02-10T12:29:40Z")

</div>

Hello everyone,

I’m currently writing a Rails application which should expose some web  
methods, which need to be called by a windows mobile application.  
I’ve been able to successfully call some webmethods from the mobile  
application, but only the methods returning simple types as strings,  
numbers, arrays etc.

Now I need to expose a method which receives an ActiveRecord object.  
In this case, I’ve witnessed a strange behaviour.  
If I write my method this way:

def get\_role(role\_id)  
a = Role.find(role\_id)  
return a  
end

I get a “Cannot map Role to SOAP/OM” exception from the mobile  
application. Googling this error has lead me to this page:  
[http://benrobb.com/2007/02/06/cannot-map-objtype-to-soapom/](http://benrobb.com/2007/02/06/cannot-map-objtype-to-soapom/)

so I rewrote the method as:

def get\_role(role\_id)  
a = Role.find(role\_id)  
return Role.new(:description =\> “#{a.description}”, …[all the  
attributes here])  
end

but in this case, the mobile application gives me a “FormatException”  
error.  
I cannot understand why, even if I’m returning a Role object in both  
cases, I get two different error messages!  
Where or what am I doing wrong?

Thanks in advance!  
Regards,  
Rey9999
