I'm trying to create a simple SOAP client in Ruby and up to this point have
been unsuccessful. Here is my code and the output. I a new to Ruby so if
there is anything else I can offer to get more assistance let me know.
require 'soap/rpc/driver'
class CustomerController < ApplicationController
ENDPOINT = "http://xxx/MyWebService/"
NAMESPACE = "http://myserver.com/namespace"
def create
end
def save_customer
soapProxy = SOAP::RPC::Driver.new(ENDPOINT,
NAMESPACE)
soapProxy.add_method('ContactNew')
soapProxy.add_method('ContactSave', 'contact')
contact = soapProxy.ContactNew
contact.FirstName = "Wes"
contact.LastName = "Shaddix"
contactKey = soapProxy.ContactSave(contact)
redirect_to(:action => "create")
end
end
OUTPUT
SOAP::PostUnavailableError in Customer#save_customer
405: Method Not Allowed
extract the code into a simple class that are easy to test...
the error code 405, indictaes that your code is broken, but your use of
the service is...check the specifications
Hi,
Wes Shaddix wrote:
I'm trying to create a simple SOAP client in Ruby and up to this point have
been unsuccessful. Here is my code and the output. I a new to Ruby so if
there is anything else I can offer to get more assistance let me know.
Can I see a wiredump of the request?
require 'soap/rpc/driver'
class CustomerController < ApplicationController
def save_customer
soapProxy = SOAP::RPC::Driver.new(ENDPOINT,
NAMESPACE)
soapProxy.add_method('ContactNew')
soapProxy.add_method('ContactSave', 'contact')
soapProxy.wiredump_dev = STDERR
Please add the above line here. Though I don't know where I get STDERR
outputs in Rails environment...
Regards,
// NaHi
The same code translated to c# works fine. That's what leads me to believe
I'm coding it wrong in Ruby.
···
-----Original Message-----
From: mikkel@gmail.com [mailto:mikkel@gmail.com]
Sent: Wednesday, October 26, 2005 3:13 PM
To: ruby-talk ML
Subject: Re: Trouble creating a SOAP client
extract the code into a simple class that are easy to test...
the error code 405, indictaes that your code is broken, but your use of
the service is...check the specifications
That helps. From the output, I was able to tell that the soap action was not
being set so instead of add_method, I now call
oapProxy.add_method_with_soapaction('ContactNew', NAMESPACE + 'ContactNew')
I'm getting the right response back from the web service when I call
ContactNew, but I'm unable to set the FirstName property on the object
returned from the call. Below is the server response after the call to
ContactNew
<?xml version="1.0" encoding="utf-8"?><soap:Envelope
xmlns:soap="Error;
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><ContactNewResponse
xmlns="Inovaware – Flexible subscription billing keeps you in control
xsi:nil="true" /><ContactID /><NamePrefix /><NameTitle /><FirstName
/><LastName /><NameSuffix /><Pronunciation /><JobTitle /><Company
/><AddressLine1 /><AddressLine2 /><City /><MailRegion /><MailCode /><Country
/><WorkNumber /><FAXNumber /><HomeNumber /><MobileNumber /><PagerNumber
/><EMailAddress /><BirthDate xsi:nil="true" /><Login /><Password
/><ModifyCount>0</ModifyCount></ContactNewResult></ContactNewResponse></soap
:Body></soap:Envelope>
And this is the call that fails:
contact = soapProxy.ContactNew
contact.FirstName = "TestFromRuby"
with the following error:
undefined method `FirstName=' for #<SOAP::Mapping::Object:0x3809a70>
···
-----Original Message-----
From: NAKAMURA, Hiroshi [mailto:nakahiro@sarion.co.jp]
Sent: Wednesday, October 26, 2005 9:02 PM
To: ruby-talk ML
Subject: Re: Trouble creating a SOAP client
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
Wes Shaddix wrote:
I'm trying to create a simple SOAP client in Ruby and up to this point
have
been unsuccessful. Here is my code and the output. I a new to Ruby so if
there is anything else I can offer to get more assistance let me know.
Can I see a wiredump of the request?
require 'soap/rpc/driver'
class CustomerController < ApplicationController
def save_customer
soapProxy = SOAP::RPC::Driver.new(ENDPOINT,
NAMESPACE)
soapProxy.add_method('ContactNew')
soapProxy.add_method('ContactSave', 'contact')
soapProxy.wiredump_dev = STDERR
Please add the above line here. Though I don't know where I get STDERR
outputs in Rails environment...
Regards,
// NaHi
Hi,
Wes Shaddix wrote:
That helps. From the output, I was able to tell that the soap action was not
being set so instead of add_method, I now call
oapProxy.add_method_with_soapaction('ContactNew', NAMESPACE + 'ContactNew')
OK.
I'm getting the right response back from the web service when I call
ContactNew, but I'm unable to set the FirstName property on the object
returned from the call. Below is the server response after the call to
ContactNew
Please use "firstName" instead of "FirstName". Method name is
uncapitalized along to Ruby's coding style.
Regards,
// NaHi