Hi,
I’m trying to write a little SOAP WSDL client to get a currency
conversion rate. I have tried what is listed below but I get the error
below. I don’t know what I’m doing but I’ve been trying to follow the
pickaxe book on page 252. Any suggestions to get this working?
Thanks,
Peter
RUBY SCRIPT
require ‘soap/wsdlDriver’
require ‘cgi’
WSDL_URL = “http://www.webservicex.net/CurrencyConvertor.asmx?WSDL”
soap = SOAP::WSDLDriverFactory.new(WSDL_URL).createDriver
result = soap.ConversionRate(“USD”, “CAD”)
puts result
ERROR
Unknown element {http://schemas.xmlsoap.org/wsdl/http/}binding.
Unknown element {http://schemas.xmlsoap.org/wsdl/http/}operation.
Unknown element {http://schemas.xmlsoap.org/wsdl/http/}urlEncoded.
Unknown element {http://schemas.xmlsoap.org/wsdl/mime/}mimeXml.
Unknown element {http://schemas.xmlsoap.org/wsdl/http/}binding.
Unknown element {http://schemas.xmlsoap.org/wsdl/http/}operation.
Unknown element {http://schemas.xmlsoap.org/wsdl/mime/}content.
Unknown element {http://schemas.xmlsoap.org/wsdl/mime/}mimeXml.
Unknown element {http://schemas.xmlsoap.org/wsdl/http/}address.
Unknown element {http://schemas.xmlsoap.org/wsdl/http/}address.
soap_currency_conversion.rb:8: undefined method `ConversionRate’ for
#SOAP::WSDLDriver:0x13202b4 (NoMethodError)
Hi Emil,
Thanks for the respone. I’ve tried what you posted and it didn’t work.
Did you test this? I got the following error
Unknown element {http://schemas.xmlsoap.org/wsdl/http/}binding.
Unknown element {http://schemas.xmlsoap.org/wsdl/http/}operation.
Unknown element {http://schemas.xmlsoap.org/wsdl/http/}urlEncoded.
Unknown element {http://schemas.xmlsoap.org/wsdl/mime/}mimeXml.
Unknown element {http://schemas.xmlsoap.org/wsdl/http/}binding.
Unknown element {http://schemas.xmlsoap.org/wsdl/http/}operation.
Unknown element {http://schemas.xmlsoap.org/wsdl/mime/}content.
Unknown element {http://schemas.xmlsoap.org/wsdl/mime/}mimeXml.
Unknown element {http://schemas.xmlsoap.org/wsdl/http/}address.
Unknown element {http://schemas.xmlsoap.org/wsdl/http/}address.
conversionWS2.rb:5: undefined method `create_rpc_driver’ for
#SOAP::WSDLDriverFactory: (NoMethodError)
I have also tried another suggestion that almost works. It always
returns a conversion rate of zero. But it is nice because it doesn’t
use WSDL.
require ‘soap/rpc/driver’
service =
SOAP::RPC::Driver.new(“http://www.webservicex.net/CurrencyConvertor.asmx","http://www.webserviceX.NET/”)
service.default_encodingstyle =
SOAP::EncodingStyle::ASPDotNetHandler::Namespace
service.add_method_with_soapaction(“ConversionRate”,
“http://www.webserviceX.NET/ConversionRate”, “FromCurrency”,
“ToCurrency”)
service.wiredump_dev = STDERR
puts service.ConversionRate(“USD”,“CAD”)
Any other ideas?
Thanks,
Peter
unknown wrote:
anyone?
Here is the example. The service is doc literal
and for those services pass the arguments as a
hash.
require ‘soap/wsdlDriver’
WSDL_URL = “http://www.webservicex.net/CurrencyConvertor.asmx?WSDL”
soap = SOAP::WSDLDriverFactory.new(WSDL_URL).create_rpc_driver
soap.wiredump_dev = STDOUT
result = soap.ConversionRate(:FromCurrency => “USD”, :ToCurrency =>
“CAD”)
puts result.conversionRateResult
The messages :
ignored element: {http://schemas.xmlsoap.org/wsdl/http/}binding
ignored element: {http://schemas.xmlsoap.org/wsdl/http/}operation
ignored element: {http://schemas.xmlsoap.org/wsdl/http/}urlEncoded
ignored element: {http://schemas.xmlsoap.org/wsdl/mime/}mimeXml
ignored element: {http://schemas.xmlsoap.org/wsdl/mime/}content
ignored element: {http://schemas.xmlsoap.org/wsdl/http/}address
are for unsupported bindings in soap4r. .NET services often include
bindings for as urlEncoded, http GET and http POST in addition to
SOAP.
cheers,
emil
Emil Marceta wrote in post #51768:
… .NET services often include bindings for as urlEncoded, http GET and
http POST in addition to SOAP.
Apologies for bumping a ridiculously old thread, but it’s exactly on the
topic I’m looking for help with. I’m working with an application that
runs a web service using POST bindings. It’s been my experience that,
even four years later, when people say “web service” they still
basically mean SOAP.
I’m wondering, though, if there are Ruby now has any support for WSDL
1.1 POST and GET bindings?
http://www.w3.org/TR/wsdl#_http
A quick Google search seems like it’s not there yet, but I wanted to
ask. I’m working with another developer using Ruby, and her job would
probably be a lot easier is she could just use wsdl2ruby or a similar
rather than have to write her own code for POST requests.
Resolved.
I upgraded to Ruby 1.8.4 and now my example code works.
This might be what you’re looking for: