Changeset 567
- Timestamp:
- 03/25/07 14:29:23 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/taskers/hefeweizen_tasker_application_send_ebXML_message.rb
r566 r567 106 106 require "#{@config['LIB_DIR']}/hefeweizen_library_utils" 107 107 108 =begin 108 @debug = @info = @warn = @error = true 109 case @config['LOG_LEVEL'] 110 when 'debug' then 111 @debug = @info = @warn = @error = true 112 when 'info' then 113 @info = @warn = @error = true 114 @debug = nil 115 when 'warn' then 116 @warn = @error = true 117 @debug = @info = nil 118 when 'error' then 119 @error = true 120 @debug = @info = @warn = nil 121 end 122 109 123 begin 110 # @logger = HefeWeizen::HefeWeizenLibrary::HefeWeizenLogger.new "#{@config['LOG_DIR']}/#{@config['LOG_FILE']}", @config['LOG_LEVEL'] 111 # @logger.info "#{$0}: HefeWeizen Tasker HTTP Sender Starting with Process ID #{$$}." 112 124 @logger = HefeWeizen::HefeWeizenLibrary::HefeWeizenLogger.new "#{@config['LOG_DIR']}/#{@config['LOG_FILE']}", @config['LOG_LEVEL'] 125 @logger.info "#{$0}: HefeWeizen Tasker HTTP Sender Starting with Process ID #{$$}." 113 126 rescue Exception => e 114 127 $stderr.puts "Error creating logger. #{e.to_s}" … … 116 129 return -1 117 130 end 118 =end 131 119 132 end 120 133 121 134 def me 122 "HefeWeizen HTTPClient"135 "HefeWeizenSendEbXMLMessageTasker" 123 136 end 124 137 125 138 def run 126 127 139 if (FileTest.exists?(@parameters_file_path) && FileTest.readable?(@parameters_file_path) && 128 140 FileTest.exists?(@ebXML_message_file_path) && FileTest.readable?(@ebXML_message_file_path)) then … … 139 151 # HTTP settings 140 152 http_url = @ebXML_message_parameters['info']['transport-protocol-endpoint'] 141 number_of_retries = @ebXML_message_parameters['info']['reliable-messaging-retries'] || 5 142 seconds_to_wait_between_retries = @ebXML_message_parameters['info']['reliable-messaging-retry-interval'] || 10 143 153 144 154 # HTTPS settings 145 155 ssl_configurations = "" 146 156 security_protocol = @ebXML_message_parameters['info']['transport-protocol-security-protocol'] 147 157 if !security_protocol.nil? and security_protocol.upcase == 'SSL' then 158 @logger.debug "#{me}: Using SSL as transport level security protocol." if @debug 148 159 # no certificate checkings for wget use argument --no-check-certificate 149 160 … … 155 166 # --certificate = -> the client certificate file path 156 167 157 # "/home/sacha/HefeWeizenHTTPS/test/test-systems/Gnaraloo/certificates/gnaraloo_ssl_server_cert/Gnaraloo_ssl_server_cacert.pem"158 # "/home/sacha/HefeWeizenHTTPS/test/test-systems/Coronation/certificates/coronation_ssl_client_cert/Coronation_ssl_client_cacert.pem"159 160 168 ca_certificate = @ebXML_message_parameters['info']['transport-protocol-security-server-cert-file'] || "" 161 169 ca_directory = @ebXML_message_parameters['info']['transport-protocol-security-server-cas-directory'] || "" … … 166 174 msg = "Required SSL configuration information is missing. Check the values of the ca_certificate: '#{ca_certificate}', " + 167 175 "ca_directory = '#{ca_directory}', client certificate: '#{client_certificate}', or priate key: '#{priate_key}'." 168 # @logger.error "#{me}: #{msg}"169 176 # ssl_configurations = "--no-check-certificate" 170 puts "Errro #{msg}" 177 @logger.error "#{me}: Errro #{msg}" if @error 178 # TODO exit -1? 171 179 else 172 180 ssl_configurations = "--ca-certificate=#{ca_certificate} --ca-directory=#{ca_directory} --certificate=#{client_certificate} --private-key=#{private_key}" … … 175 183 end 176 184 177 # F IX ME FOR TESTING PURPOSE SEND IT TO A LOCAL WEBSERVER185 # FOR TESTING PURPOSE SEND IT TO A LOCAL WEBSERVER 178 186 # http_url = "localhost:5555/test" 179 187 180 # F IX ME FOR TESTING PURPOSE SEND IT TO A LOCAL WEBSERVER188 # FOR TESTING PURPOSE SEND IT TO A LOCAL WEBSERVER 181 189 # http_url = "192.168.1.49:8888/gnaraloo" 182 190 … … 187 195 transfer_info_file_path = "#{@config['TEMP_FILE_DIR']}/#{@pid}_transfer_#{time}_#{time2}" 188 196 189 190 197 extra_header = nil 191 198 … … 195 202 extra_header = 'Content-Type: text/xml' 196 203 end 197 198 # TODO 199 # maybe do sending individually and keep track of retries. this would allow 200 # to send status information to big_ania to let the transaction know about 201 # individual failed attempts 202 203 # command = "wget -S --user-agent=\"HefeWeizen\" --post-file=#{@ebXML_message_file_path} --header='#{extra_header}' --header='SOAPAction: \"ebXML\"' --output-document=#{response_file_path} --tries=#{number_of_retries} --wait=#{seconds_to_wait_between_retries} --quiet #{http_url}" 204 # command = "wget -S --user-agent=\"HefeWeizen\" --post-file=#{@ebXML_message_file_path} --header='#{extra_header}' --header='SOAPAction: \"ebXML\"' --output-document=#{response_file_path} --tries=#{number_of_retries} --wait=#{seconds_to_wait_between_retries} --append-output=#{transfer_info_file_path} #{http_url} " 205 # no retries here! 206 207 208 # puts command = "wget -S --user-agent=\"HefeWeizen\" --post-file=\"#{@ebXML_message_file_path}\" --header='#{extra_header}' --header='SOAPAction: \"ebXML\"' --output-document=\"#{response_file_path}\" --append-output=\"#{transfer_info_file_path}\" #{http_url} " 209 204 205 @logger.debug "#{me}: Extra headers for HTTP post: #{extra_header}" if @debug 210 206 # added ignore-length ... had problems with it when using webrick and setting code 204 to it. 211 212 207 command = "wget -S #{ssl_configurations} --ignore-length --user-agent=\"HefeWeizen\" --post-file=\"#{@ebXML_message_file_path}\" --header='#{extra_header}' --header='SOAPAction: \"ebXML\"' --output-document=\"#{response_file_path}\" --append-output=\"#{transfer_info_file_path}\" #{http_url} " 213 208 209 @logger.debug "#{me}: Complete HTTP post command: #{command}" if @debug 214 210 system(command) 215 216 211 success = $? 217 212 218 # puts "-----------------HTTP SENDER---response-------------------"219 # require 'pp'220 # pp File.read(response_file_path)221 # puts "-----------------HTTP SENDER---response-------------------"222 223 213 elsif @ebXML_message_parameters['info']['transport-protocol-name'].upcase == "SMTP" then 224 puts 'SMTP not implemented yet'214 @logger.error "#{me}: SMTP not implemented yet " if @error 225 215 success = -1 226 exit -1227 216 end 228 217 … … 241 230 242 231 test_response = false 232 243 233 if @ebXML_message_parameters['info']['transport-protocol-name'].upcase == "HTTP" then 244 234 235 # The code below will be used in the test environment. 236 # It will check if there is a directive that tells the client to throw away a response (usefule 237 # to test reliable messaging). 245 238 if @config['BIG_ANIA_LOAD_TEST_ENVIRONMENT'] == 'true' then 246 247 239 file_path = "#{@config['TEMP_FILE_DIR']}/client_throw_away_message_response_#{@b2b_system_name}" 248 240 if File.exists?(file_path) then … … 252 244 accepted_time_difference = 30*60 253 245 if time_difference > accepted_time_difference then 254 puts "Time difference too big (#{time_difference} instead of #{accepted_time_difference}). Just in case someone forgot such a file in this place."246 @logger.debug "Time difference too big (#{time_difference} instead of #{accepted_time_difference}). Just in case someone forgot such a file in this place." if @debug 255 247 else 256 248 test_response = true … … 296 288 else 297 289 command_hash['status'] = "FAILED" 298 command_hash['reason'] = " HTTPsender task was unable to deliver the message."290 command_hash['reason'] = "ebXML message sender task was unable to deliver the message." 299 291 end 300 292 301 293 my_command = "echo \"#{HefeWeizen::HefeWeizenLibrary::HefeWeizenCommand.hash_to_command command_hash}\" > #{@pipe_to_ania}" 294 @logger.debug "#{me}: Sending back result to Big Ania: #{my_command}" if @debug 302 295 system my_command 303 296
