Skip to content
Browse files

-submission bugs (soap faults should be displayed)

  - fix for errors requiring a restard due to chdir
  - upload feature
  - remove implicit .xml file extension
  • Loading branch information...
1 parent e3ef68f commit 95aca162290ef40390618d11d78918a487b5d75f sam committed Jul 8, 2009
Showing with 94 additions and 65 deletions.
  1. +17 −8 app.rb
  2. +26 −23 lib/generator_helpers.rb
  3. +19 −16 lib/sinatra_app_helpers.rb
  4. +9 −6 lib/soap4r2ruby.rb
  5. +11 −7 todo.txt
  6. +11 −4 views/client.haml
  7. +1 −1 views/result.haml
View
25 app.rb
@@ -7,11 +7,8 @@
require File.dirname(File.expand_path(__FILE__))+'/lib/sinatra_app_helpers'
-
-#on restart clear out the generated clients
-%x{rake maintenance:clean}
-#start page to select the wsdl
get '/**' do
+ #start page to select the wsdl
haml :choose_wsdl
end
@@ -48,6 +45,11 @@
haml :client
end
+post '/upload_file' do
+ require 'ruby-debug';debugger
+ haml :client
+end
+
post '/update' do
@client = @params[:client]
@wsdl = @params[:wsdl]
@@ -68,15 +70,22 @@
#@result = File.open("test/fixtures/sample_xmls/working_vdev_sample_request.xml").readlines.to_s
# content_type 'text/xml', :charset => 'utf-8'
haml :result
- elsif @params[:action] == 'Save'
+ elsif @params[:action] == 'SaveRequest'
# SaveLoadConvertHelpers::save_request_as_yaml(@params,"saved_forms/"+@params["file_name"]+".yml")
- SaveLoadConvertHelpers::save_request_xml(@input, "saved_forms/"+@params["file_name"]+".xml", @client, @namespace, @wsdl)
- haml :client
+ SaveLoadConvertHelpers::save_request_xml(@input, "saved_forms/requests/"+@params["file_name"], @client, @namespace, @wsdl)
+ haml :client
+ elsif @params[:action] == 'SaveResponse'
+ # SaveLoadConvertHelpers::save_request_as_yaml(@params,"saved_forms/"+@params["file_name"]+".yml")
+ SaveLoadConvertHelpers::save_request_xml(@input, "saved_forms/responses/"+@params["file_name"], @client, @namespace, @wsdl)
+ haml :client
elsif @params[:action] == 'Load'
#@params = SaveLoadConvertHelpers::load_request_from_yaml("saved_forms/"+@params["file_name"]+".yml")
- @params['input'] = SaveLoadConvertHelpers::load_request_xml("saved_forms/"+@params["file_name"]+".xml", @client, @namespace, @wsdl)
+ @params['input'] = SaveLoadConvertHelpers::load_request_xml("saved_forms/requests"+@params["file_name"], @client, @namespace, @wsdl)
@input = @params['input']
haml :client
+ elsif @params[:action] == 'Upload'
+ File.open("saved_forms/#{@params['datafile'][:filename]}", "w+").syswrite(@params["datafile"][:tempfile].readlines)
+ haml :client
elsif @params[:action] == 'Add'
@input = SinatraAppHelpers::create_element(@input, @params[:element])
haml :client
View
49 lib/generator_helpers.rb
@@ -6,29 +6,32 @@ module GeneratorHelpers
## helpers
def self.generate_ruby_classes(folder_name, namespace, wsdl)
curr = Dir.pwd
- self.cleanup_generated_ruby_classes(folder_name)
- Dir.mkdir folder_name
- Dir.chdir folder_name
- i = WSDL::SOAP::WSDL2Ruby.new
- i.instance_variable_set("@name", 'default')
- i.instance_variable_set("@location", wsdl)
- opt = {}
- opt["force"] = true
- opt['classdef'] = nil
- opt['mapping_registry'] = nil
- opt['driver'] = nil
- opt['classdef_filename'] = '.rb'
- opt["module_path"] = namespace
- i.instance_variable_set("@opt", opt)
- i.run
- #
- # command = "wsdl2ruby.rb --module_path #{namespace} --wsdl #{wsdl} --classdef --mapping_registry --driver --force"
- # require 'ruby-debug';debugger
- # result = %x{command}
- make_unique_name_for_generated_ruby_classes(Dir.pwd)
- driver_file = Dir.entries(Dir.pwd).grep(/Driver.rb/).first
- Dir.chdir curr
- driver_file
+ begin
+ self.cleanup_generated_ruby_classes(folder_name)
+ Dir.mkdir folder_name
+ Dir.chdir folder_name
+ i = WSDL::SOAP::WSDL2Ruby.new
+ i.instance_variable_set("@name", 'default')
+ i.instance_variable_set("@location", wsdl)
+ opt = {}
+ opt["force"] = true
+ opt['classdef'] = nil
+ opt['mapping_registry'] = nil
+ opt['driver'] = nil
+ opt['classdef_filename'] = '.rb'
+ opt["module_path"] = namespace
+ i.instance_variable_set("@opt", opt)
+ i.run
+ #
+ # command = "wsdl2ruby.rb --module_path #{namespace} --wsdl #{wsdl} --classdef --mapping_registry --driver --force"
+ # require 'ruby-debug';debugger
+ # result = %x{command}
+ make_unique_name_for_generated_ruby_classes(Dir.pwd)
+ driver_file = Dir.entries(Dir.pwd).grep(/Driver.rb/).first
+ ensure
+ Dir.chdir curr
+ driver_file
+ end
end
def self.make_unique_name_for_generated_ruby_classes(folder_name)
View
35 lib/sinatra_app_helpers.rb
@@ -6,23 +6,26 @@ module SinatraAppHelpers
def self.update(params)
folder = params['client']
curr = Dir.pwd
- Dir.chdir(folder)
- driver_file =(Dir.entries(folder) - [".", "..", ".svn"]).select{|e| e.to_s.include?'Driver.rb'}.first
- require folder+"/"+driver_file
- Dir.chdir(curr)
- @input = YAML.load params['input'] #prepopulate with original values
- (params.keys - ["input", :splat, "namespace", "client", "action", "Submit", "Save", "Load", "file_name"]).sort.each do |e|
- es = e.to_array
- #since yaml turns everything to strings make sure occurences turn back into Numbers properly
- # to_i on nil gives zero not nil
- if((es.include?('.minoccurs') || es.include?('.maxoccurs')) and (eval("params[e]") != ''))
- eval("#{es} = params[e].to_i")
- else
- eval("#{es} = params[e]")
- end
+ begin
+ Dir.chdir(folder)
+ driver_file =(Dir.entries(folder) - [".", "..", ".svn"]).select{|e| e.to_s.include?'Driver.rb'}.first
+ require folder+"/"+driver_file
+ ensure
+ Dir.chdir curr
end
- params['input'] = @input #restore updated values
- params
+ @input = YAML.load params['input'] #prepopulate with original values
+ (params.keys - ["input", :splat, "namespace", "client", "action", "Submit", "Save", "Load", "file_name"]).sort.each do |e|
+ es = e.to_array
+ #since yaml turns everything to strings make sure occurences turn back into Numbers properly
+ # to_i on nil gives zero not nil
+ if((es.include?('.minoccurs') || es.include?('.maxoccurs')) and (eval("params[e]") != ''))
+ eval("#{es} = params[e].to_i")
+ else
+ eval("#{es} = params[e]")
+ end
+ end
+ params['input'] = @input #restore updated values
+ params
end
def self.create_element(input, element)
View
15 lib/soap4r2ruby.rb
@@ -21,12 +21,15 @@ def initialize(client_folder, i_namespace, wsdl)
@namespace = i_namespace
@wsdl = wsdl
curr = Dir.pwd
- Dir.chdir(@folder)
- # $DEBUG = true=
- @driver_file =(Dir.entries(@folder) - [".", "..", ".svn"]).select{|e| e.to_s.include?'Driver.rb'}.first
- require @folder+"/"+@driver_file
- Dir.chdir(curr)
-
+ begin
+ Dir.chdir(@folder)
+ # $DEBUG = true=
+ @driver_file =(Dir.entries(@folder) - [".", "..", ".svn"]).select{|e| e.to_s.include?'Driver.rb'}.first
+ require @folder+"/"+@driver_file
+ ensure
+ Dir.chdir curr
+ end
+
@factory = SOAP::WSDLDriverFactory.new(@wsdl)
@port_type = @factory.wsdl.porttypes[0]
# @service_method_names = @port_type.operations.map{|op| op}
View
18 todo.txt
@@ -1,10 +1,13 @@
todo:
- - upload feature
+ - add nillable to the attributes of each element
- fix for booleans
- fix for nillable false minoccurs = 0
+ - nil PromotionId, AppliedStatus, and QualifyType bugs.
- get all demo xmls working
- -submission bugs (soap faults should be displayed)
- -cleanup temporary files
+ - bug for backslashes for local files on windows systems
+ -loading bug - needs to build default instance then populate it.
+ -cleanup temporary files on startup
+
-serve this as web app (finalize on war or ruby web server) (rake task)
-create a java exectuable that works for mac osx and windows xp (rake task)
java -cp "ruby-processing/app.rb:ruby-processing/exporters/applet_exporter.rb:ruby-processing/exporters/application_exporter.rb:ruby-processing/exporters/base_exporter.rb:ruby-processing/exporters/creator.rb:ruby-processing/helpers/numeric.rb:ruby-processing/helpers/string.rb:ruby-processing/runner.rb:ruby-processing/runners/base.rb:ruby-processing/runners/live.rb:ruby-processing/runners/run.rb:ruby-processing/runners/watch.rb:ruby-processing.rb:sand_chaser.rb:core/core.jar:core/jruby-complete.jar:jogl.jar:opengl.jar" org.jruby.Main ruby-processing/runners/run.rb sand_chaser.rb
@@ -13,21 +16,22 @@ todo:
-findInventory array build default instance with Array of complextype bug
-ICmfindInventory build default instance with SchemaSequenceDefinition bug
- - nil PromotionId, AppliedStatus, and QualifyType bugs.
-receipt messages bug missing on load.
-min max occurs disappears on reload.
-make enums work as select boxes need to figure a way to make nil preserve the enum type dynamically
- - bug for backslashes for local files on windows systems
-mouse over table highlight
-create a quick driver to generate ruby tests
-create a gui to do a visual diff of expected responses vs actual responses.
-google / amazon / ebay working examples
- -loading bug - needs to build default instance then populate it.
done:
- - manually create and submit an xml
+ -submission bugs (soap faults should be displayed)
+ - fix for errors requiring a restard due to chdir
+ - upload feature
+ - remove implicit .xml file extension
+ -manually create and submit an xml
-fix on restart of server having to go back to the method selector page.
-make sure the appliedStatus is returned correctly from the server
-result display bugs -may already be fixed with the array of simple types fix
View
15 views/client.haml
@@ -10,7 +10,7 @@
WebClient Generated From Wsdl
= @params[:method]
%div
- %form{:action => '/update', :method => 'post'}
+ %form{ :enctype => "multipart/form-data", :method => "post", :action => "update" }
/Store the old state/
%input{:type => :hidden, :name => :input, :value => @input.to_yaml}
%input{:type => :hidden, :name => :client, :value => @client}
@@ -34,6 +34,13 @@
filename:
%small
(defaults to .xml extension)
- %input{:type => :text, :id => "file_name", :name => "file_name", :value => ''}
- %input{:type => 'submit', :name => 'Save',:value => 'Save', :onclick => "document.getElementById(\"action\").value = \"Save\";"}
- %input{:type => 'submit', :name => 'Load',:value => 'Load', :onclick => "document.getElementById(\"action\").value = \"Load\";"}
+ %input{:type => :text, :id => "file_name", :name => "file_name", :value => ''}
+ %input{:type => 'submit', :name => 'SaveRequest',:value => 'SaveRequest', :onclick => "document.getElementById(\"action\").value = \"SaveRequest\";"}
+ %input{:type => 'submit', :name => 'Load',:value => 'Load', :onclick => "document.getElementById(\"action\").value = \"Load\";"}
+ %div
+ %label
+ fileupload:
+ %input{ :name => "datafile", :size => "40", :type => "file" }
+ %input{:type => 'submit', :name => 'Upload',:value => 'Upload', :onclick => "document.getElementById(\"action\").value = \"Upload\";"}
+
+
View
2 views/result.haml
@@ -32,5 +32,5 @@
%small
(defaults to .xml extension)
%input{:type => :text, :id => "file_name", :name => "file_name", :value => ''}
- %input{:type => 'submit', :name => 'Save',:value => 'Save', :onclick => "document.getElementById(\"action\").value = \"Save\";"}
+ %input{:type => 'submit', :name => 'SaveResult',:value => 'SaveResult', :onclick => "document.getElementById(\"action\").value = \"SaveResult\";"}

0 comments on commit 95aca16

Please sign in to comment.
Something went wrong with that request. Please try again.