In Savon with wsse authentication, my nonce token gets reused on subsequent requests

StackOverflow https://stackoverflow.com/questions/4823478

  •  26-10-2019
  •  | 
  •  

Pergunta

Perhaps I'm just not writing idiomatic code for savon, so please feel free to straighten me out, but I was trying to make multiple requests on the same client, as demonstrated in

client=Savon::Client.new {
  wsdl.document=wsdl_path
}

r1=client.request(:company_get_report_suites) do
  wsse.credentials APP_CONFIG['omniture']['username'],APP_CONFIG['omniture']['shared_secret'],:digest
end

r2=client.request(:scheduling_get_reports_run_history) do
  wsse.credentials APP_CONFIG['omniture']['username'],APP_CONFIG['omniture']['shared_secret'],:digest
end

The second request ends up reusing the nonce. The point of the wsse nonce is to use it only once, so the service I'm calling complains that I've reused it and refuses to service the request. My first thought was to add a timestamp, but that didn't help; in fact, the source code shows the nonce is used if set, and generated only if not previously set.

Obviously, if I must, I can create a new client, but that's a rather heavy-weight operation and seems unlikely to be the normal way to create multiple requests off of the same client.

Is there a sensible workaround?

Foi útil?

Solução

This makes me feel dirty, but if no one can suggest a better alternative, this does the trick:

class Savon::WSSE
  def reset_nonce
    @nonce=nil
    @nonce=nonce
  end
end

r1=client.request(:company_get_report_suites) do
  wsse.reset_nonce
end
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top