Open eiapopeia opened 8 years ago
This would be extremely useful!
Savon::Builder#build_document needs to create the headers 3 times instead of 2. I.e, replace "2.do" with "3.do" I do not yet know why. For some reason Signature#document needs to be mutated that many times.
One can call build_document an extra time before initiating the request, or add this to lib/savon/builder.rb:
def get_xml
tag(builder, :Envelope, namespaces_with_globals) do |xml|
tag(xml, :Header, header_attributes) { xml << header.to_s } unless header.empty?
if @globals[:no_message_tag]
tag(xml, :Body, body_attributes) { xml << message.to_s }
else
tag(xml, :Body, body_attributes) { xml.tag!(*namespaced_message_tag) { xml << message.to_s } }
end
end
end
def build_document
return get_xml unless @signature
# if we have a signature sign the document
if @signature
@signature.document = get_xml
2.times do
@header = nil
@signature.document = get_xml
end
return @signature.document
end
end
To do this you have to give the timestamp-option to the _wssesignature! Like so:
It is also possible to give created_at and/or expires_at like this