Search code examples
rubysoapsoapuisavon

301 Error on SOAP API


I am trying to reach a SOAP API with these restrictions per the API instructions:

  1. Authentication method is http_base_auth, client applications can leverage both HTTP and HTTPS protocols for authentication.

  2. PaaS corporate account login & Password has to be passed through SOAP headers. SOAP has an API to set the user ID/password for HTTP basic authentication.

Right now this is what I have:

require 'savon'

client = Savon.client(basic_auth: ['paas_login_info', 'paas_password_info'], wsdl:    "http://www.webiste.com/us/paas/s3PaaS.wsdl")

message = {"CUSTOMER_ID" => 55555555555, "EMPLOYEE_ID" => 1111}

response = client.call(:s3_paas_add_something, message: message, soap_header: {'login' => 'pass_login_info', 'password' => 'paas_password_info'})

p response #=> <h1>Moved Permanently</h1> <p>The document has moved <a href="http://www.website.com/us/paas/PaaSServer.php">here</a>.</p>

I'm duplicating the pass_login_info and pass_password_info because I really don't understand how to meet both requirements, but when I get rid of either/both I still get this error when I think I am pinging the API.

Other weird note, when I put this into SOAPUI my service didn't show ANY of the operations, like it does with other test services like http://www.webservicex.net/uszip.asmx?WSDL


Solution

  • Hello select_the_choice,

    I really don't see the question but since I've struggled enough time to integrate a magento platform into a rails app, I will try to help you.

    First of all I suggest you to use REST if you can. Is going to be much faster and even if the authentication seems a little bit harder first, everything is going to be easier in the future.

    If you want to continue with SOAP, make sure you have the second version of savon.

    I don't know exactly what are you trying to do and what are your endpoints but this is how a SOAP to magento request should look like

    host = "http://website.com/index.php/api/v2_soap/index/?wsdl=1"
    client = Savon.client(wsdl: host)
    
    session_id = client.call(:login, message: {
      username: "YOUR_USERNAME",
      api_key: "YOUR_PASSWORD"
    }).body[:login_response][:login_return]
    
    client.call(:customer_customer_create, message: {
      sessionId: session_id,
      customerData: [{
        firstname: self.profile.first_name, # let's say we are in User model
        lastname: self.profile.last_name
      }]
    })
    

    Hope it helps!