Trouble creating a SOAP client

Discussion in 'Ruby' started by Wes Shaddix, Oct 26, 2005.

  1. Wes Shaddix

    Wes Shaddix Guest

    ------=_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--
     
    Wes Shaddix, Oct 26, 2005
    #1
    1. Advertising

  2. Wes Shaddix

    Guest

    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
     
    , Oct 26, 2005
    #2
    1. Advertising

  3. Wes Shaddix

    Wes Shaddix Guest

    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: [mailto:]
    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
     
    Wes Shaddix, Oct 26, 2005
    #3
  4. -----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
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.1 (Cygwin)

    iD8DBQFDYCcQf6b33ts2dPkRAsgYAKDEuMQcKTq9B8N2evMRIavH1opEtgCgmZAC
    xzQ1AZGf6oPRv+qownkdruM=
    =35we
    -----END PGP SIGNATURE-----
     
    NAKAMURA, Hiroshi, Oct 27, 2005
    #4
  5. Wes Shaddix

    Wes Shaddix Guest

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

    iD8DBQFDYCcQf6b33ts2dPkRAsgYAKDEuMQcKTq9B8N2evMRIavH1opEtgCgmZAC
    xzQ1AZGf6oPRv+qownkdruM=
    =35we
    -----END PGP SIGNATURE-----
     
    Wes Shaddix, Oct 27, 2005
    #5
  6. -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

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

    iD8DBQFDYXOFf6b33ts2dPkRAuxLAKC02UV7aWM5QPJKbH4EGkoplT6VCgCffIHh
    v6nBZH1DYWpDZiw1bZzMOpE=
    =AFn7
    -----END PGP SIGNATURE-----
     
    NAKAMURA, Hiroshi, Oct 28, 2005
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sham Ramakrishnan
    Replies:
    2
    Views:
    8,384
    Sham Ramakrishnan
    Jul 1, 2003
  2. Bruce

    client-to-client communication via SOAP

    Bruce, Mar 21, 2005, in forum: ASP .Net Web Services
    Replies:
    3
    Views:
    256
    [MSFT]
    Mar 28, 2005
  3. Bruce

    client-to-client communication via SOAP

    Bruce, Mar 24, 2005, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    152
    Bruce
    Mar 24, 2005
  4. Replies:
    0
    Views:
    219
  5. Mason Brown
    Replies:
    1
    Views:
    381
Loading...

Share This Page