Rails and Webmotors

5

Anyone with any experience with Rails integration with Webmotors APi?

I'm using Gem SAVON to integrate the application with the site API and I'm getting the error:

  

Savon :: SOAPFault: (soap: Server) Server was unable to process request.   --- > Object reference not set to an instance of an object.

What I'm doing is:

def self.login_webmotors
      cnpj = "xxxxxxxxxx"
      email = "xxxxxxxx"
      senha = "xxxxxxxx"
      #wdsl_add = 'http://www.webmotors.com.br/IntegracaoRevendedor/wsEstoqueRevendedorWebMotors.asmx?WSDL'
      login_url = 'http://www.webmotors.com.br/IntegracaoRevendedor/wsLoginSistemaRevendedor.asmx?WSDL'
      login = Savon.client(wsdl: login_url,
                                log: true,
                                log_level: :debug,
                                pretty_print_xml: true)

      response = login.call(:autenticar, message: { cnpj: cnpj, email: email, senha: senha })

      Rails.application.config.hash_webmotors = response.body[:autenticar_response][:autenticar_result][:hash_autenticacao]

      Savon.client(headers: { "hash_autenticacao" => Rails.application.config.hash_webmotors })
    end

then:

def self.adicionar_carro
    login_webmotors

    wDSL = 'http://www.webmotors.com.br/IntegracaoRevendedor/wsEstoqueRevendedorWebMotors.asmx?WSDL'

    add = Savon.client(wsdl: wDSL,
                            log: true,
                            log_level: :debug,
                            pretty_print_xml: true)

    message = { codigo_anuncio: 1234, 
                codigo_modalidade: 1, 
                tipo_anuncio: "teste", 
                codigo_marca: 1, 
                codigo_modelo: 1, 
                codigo_versao: 1, 
                ano_modelo: 2000, 
                ano_fabricacao: 1995, 
                km: 20000, 
                placa: "pg1234", 
                codigo_cambio: 1  }

    carro = add.call(:incluir_carro, message: message )
end

But I always stumble on the same error

  

Savon :: SOAPFault: (soap: Server) Server was unable to process request.   --- > Object reference not set to an instance of an object.

    
asked by anonymous 24.12.2015 / 15:22

1 answer

1

To complete the problem, I contacted Webmotors and they replied that by not releasing APi for new systems, it is only working for systems that have already been approved. That is, any attempt to integrate the system today is useless.

    
02.01.2016 / 20:24