# ActionWebService & soap

**URL:** <https://www.ruby-forum.com/t/actionwebservice-soap/143690>\
**Category:** Rails\
**Created:** [July 21, 2008, 9:25pm UTC](https://www.ruby-forum.com/t/actionwebservice-soap/143690 "2008-07-21T21:25:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fox](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/c5a1d2/32.png) [@fox](https://www.ruby-forum.com/u/fox)\
**Post date:** [July 21, 2008, 9:25pm UTC](https://www.ruby-forum.com/t/actionwebservice-soap/143690/1 "2008-07-21T21:25:37Z")

</div>

Hi everyone,  
I’m writing a Rails application which accepts file uploads via a form  
and tracks them in a database - pretty simple stuff.  
I now want to write a soap api to enable similar functionality from php  
scripts.  
Basically, I can get ActionWebService to publish a wsdl and I can go to  
the url of the methods I create, but I’m not sure how to handle the file  
upload part.

Are there any examples of this anywhere? Unfortunately, I can’t find  
much, other than the initial config for Rails 2.0.

thanks in advance,  
O

---

<div class="post-metadata">

**Author:** ![fox](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/c5a1d2/32.png) [@fox](https://www.ruby-forum.com/u/fox)\
**Post date:** [July 21, 2008, 10:22pm UTC](https://www.ruby-forum.com/t/actionwebservice-soap/143690/2 "2008-07-21T22:22:22Z")

</div>

On Jul 21, 3:25 pm, Oliver F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hi everyone,  
> I’m writing a Rails application which accepts file uploads via a form  
> and tracks them in a database - pretty simple stuff.  
> I now want to write a soap api to enable similar functionality from php  
> scripts.  
> Basically, I can get ActionWebService to publish a wsdl and I can go to  
> the url of the methods I create, but I’m not sure how to handle the file  
> upload part.

The WSDL should have all the information required to upload data to  
the service. If you want sample code, you may be able to generate it  
from the WSDL using wsdl2ruby from the SOAP4R library. I wrote a  
getting started guide here:  
[http://markthomas.org/2007/09/12/getting-started-with-soap4r/](http://markthomas.org/2007/09/12/getting-started-with-soap4r/)

Hope that helps.

- Mark.

---

<div class="post-metadata">

**Author:** ![fox](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/c5a1d2/32.png) [@fox](https://www.ruby-forum.com/u/fox)\
**Post date:** [July 22, 2008, 6:14pm UTC](https://www.ruby-forum.com/t/actionwebservice-soap/143690/3 "2008-07-22T18:14:31Z")

</div>

Mark T. wrote:

> The WSDL should have all the information required to upload data to  
> the service. If you want sample code, you may be able to generate it  
> from the WSDL using wsdl2ruby from the SOAP4R library. I wrote a  
> getting started guide here:  
> [markthomas.org](http://markthomas.org/2007/09/12/getting-started-with-soap4r/)
> 
> Hope that helps.
> 
> - Mark.

Hi Mark,  
thanks for the reply, and link - some good stuff there!  
I’ve got things kind of working now. I can connect to my soap service  
and call the create\_document method with a few parameters. The problem  
is, if the file is big (say 400Mb), it requires loading it into memory  
on the consumer side and then again when it is transferred.

The server does something like:  
#(document) is a array of strings  
def create\_document(name,document)  
output = open(Tempfile.new(name),‘w’)  
output.write(document.join())  
output.close  
return output.path  
end

The file is readable and things work. Is it possible, in the event of  
having a large file, to stream the file to the server in chunks?  
I’ve found various code snippets, like adding  
def in\_chunks(size=1024) ; yield read(size) until eof? ; end  
to File, but in terms of using it in the client - I’m stumped  
(especially since I need to use PHP also).

Do you guys think SOAP is the right mechanism for this, or should I now  
be using REST? (with REST, I’d http::post the above to my  
create\_document method?)

best,  
a confused O.
