Trouble creating a SOAP client

W

Wes Shaddix

------=_NextPart_000_0027_01C5DA34.99A48DE0
Content-Type: text/plain;
charset="US-ASCII"
Content-Transfer-Encoding: 7bit

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


------=_NextPart_000_0027_01C5DA34.99A48DE0--
 
M

mikkel

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
 
W

Wes Shaddix

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: (e-mail address removed) [mailto:[email protected]]
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
 
N

NAKAMURA, Hiroshi

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

Wes said:
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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)

iD8DBQFDYCcQf6b33ts2dPkRAsgYAKDEuMQcKTq9B8N2evMRIavH1opEtgCgmZAC
xzQ1AZGf6oPRv+qownkdruM=
=35we
-----END PGP SIGNATURE-----
 
W

Wes Shaddix

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="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><ContactNewResponse
xmlns="http://inovaware.com/prism/"><ContactNewResult><ContactKey
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:[email protected]]
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 said:
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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)

iD8DBQFDYCcQf6b33ts2dPkRAsgYAKDEuMQcKTq9B8N2evMRIavH1opEtgCgmZAC
xzQ1AZGf6oPRv+qownkdruM=
=35we
-----END PGP SIGNATURE-----
 
N

NAKAMURA, Hiroshi

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

Wes said:
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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)

iD8DBQFDYXOFf6b33ts2dPkRAuxLAKC02UV7aWM5QPJKbH4EGkoplT6VCgCffIHh
v6nBZH1DYWpDZiw1bZzMOpE=
=AFn7
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top