Most systems take parameters that are easy to handle, and when this is the case SOAP4R
will always let you call that service dynamically. Doing all this computation at runtime can be
a major performance bottleneck, so even in this case you might be better off using another
solution.
Using Stubs
Arguably the best way to invoke WSDL services is to use a code generator that reads the WSDL
file and then generates proxy stubs that invoke the SOAP call correctly. One of the reasons that
this model is superior is because SOAP4R can??™t handle all types of calls dynamically. For example,
a call to AWS requires the code to be pregenerated, because the calls need an argument
that is a complex type.
It is still easy to accomplish this with SOAP4R, though, using the wsdl2ruby.rb command.
Unfortunately, this utility part of SOAP4R isn??™t available in the Ruby core distribution, so you
need to install the soap4r Gem. This adds the wsdl2ruby.rb file into your bin directory. Create
an empty directory and execute this command in it:
jruby -S wsdl2ruby --type client
--wsdl http://soap.amazon.com/schemas3/AmazonWebServices.wsdl
The output of this command will generate three different files. These files are called
AmazonSearch.rb, AmazonSearchDriver.rb, and AmazonSearchServiceClient.rb. The file
AmazonSearch.rb contains information about all the complex types this web service supports.
Because Amazon??™s web services are large, there are many classes in this file.
Pages:
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331