Elmor Elmor - 1 year ago 214
Ruby Question

rails pass soap basic auth with savon

I'm trying to send soap request with basic authentication with

savon gem

My soap server is set up with
wash_out gem

class OrdersController < ApplicationController
soap_service namespace: 'sir:WashOut', wsse_username: SIRA[:auth][:username], wsse_password: SIRA[:auth][:password]


When i make a request to soap server via
i get an error:

@client = Savon.client(
wsdl: "http://localhost:3000/orders/wsdl",
soap_header: { 'Username' =>SIRA[:auth][:username], 'Password' => SIRA[:auth][:password] }

@response = @client.call(:notify ).to_hash

On the last command i get an error

Savon::SOAPFault: (Server) Missing required UsernameToken

Answer Source

I've tried this and it works!

@client = Savon.client(
  wsdl:  "http://localhost:3000/orders/wsdl",
  wsse_auth: [SIRENA[:auth][:username], SIRENA[:auth][:password] ],
  logger: Rails.logger

 @response = @client.call(:notify,  ).to_hash