Skip to content

Commit

Permalink
WIP, working around 1.8 -> 1.9 problems by importing soap libraries f…
Browse files Browse the repository at this point in the history
…rom 1.8.7
  • Loading branch information
edebill committed Aug 29, 2010
1 parent bc1ade5 commit a008d49
Show file tree
Hide file tree
Showing 149 changed files with 18,451 additions and 33 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -2,3 +2,5 @@
debug.log
actionwebservice_unittest.db
*.gem
*~
.#*
2 changes: 2 additions & 0 deletions .rvmrc
@@ -0,0 +1,2 @@
rvm use ruby-1.9.2@actionwebservice

5 changes: 5 additions & 0 deletions Gemfile
@@ -0,0 +1,5 @@
source "http://rubygems.org"

gem 'actionpack', '3.0.0.rc2'
gem 'activerecord', '3.0.0.rc2'
gem 'activesupport', '3.0.0.rc2'
17 changes: 11 additions & 6 deletions lib/action_web_service.rb
Expand Up @@ -22,14 +22,19 @@
#++

begin
require 'active_support'
require 'action_controller'
require 'active_record'
require 'activesupport'
require 'actioncontroller'
require 'activerecord'
require 'activesupport'
require 'actionpack'
require 'active_support/core_ext/class/inheritable_attributes'
require 'action_dispatch/routing'
rescue LoadError
require 'rubygems'
gem 'activesupport', '>= 2.3.0'
gem 'actionpack', '>= 2.3.0'
gem 'activerecord', '>= 2.3.0'
gem 'activesupport', '3.0.0.rc2'
gem 'actionpack', '3.0.0.rc2'
gem 'activerecord', '3.0.0.rc2'
gem 'activesupport', '3.0.0.rc2'
end

$:.unshift(File.dirname(__FILE__) + "/action_web_service/vendor/")
Expand Down
2 changes: 1 addition & 1 deletion lib/action_web_service/client/soap_client.rb
@@ -1,4 +1,4 @@
require 'soap/rpc/driver'
require 'action_web_service/soap/rpc/driver'
require 'uri'

module ActionWebService # :nodoc:
Expand Down
Expand Up @@ -61,7 +61,7 @@ def require_web_service_api(name) # :nodoc:
begin
require_dependency(file_name)
rescue LoadError => load_error
requiree = / -- (.*?)(\.rb)?$/.match(load_error).to_a[1]
requiree = / -- (.*?)(\.rb)?$/.match(load_error.to_s).to_a[1]
msg = requiree == file_name ? "Missing API definition file in apis/#{file_name}.rb" : "Can't load file: #{requiree}"
raise LoadError.new(msg).copy_blame!(load_error)
end
Expand Down
Expand Up @@ -217,9 +217,9 @@ def to_wsdl
when binding.type.array?
xm.xsd(:complexType, 'name' => binding.type_name) do
xm.xsd(:complexContent) do
xm.xsd(:restriction, 'base' => 'soapenc:Array') do
xm.xsd(:attribute, 'ref' => 'soapenc:arrayType',
'wsdl:arrayType' => binding.element_binding.qualified_type_name('typens') + '[]')
xm.xsd(:restriction, 'base' => 'action_web_service/soapenc:Array') do
xm.xsd(:attribute, 'ref' => 'action_web_service/soapenc:arrayType',
'action_web_service/wsdl:arrayType' => binding.element_binding.qualified_type_name('typens') + '[]')
end
end
end
Expand Down Expand Up @@ -290,7 +290,7 @@ def to_wsdl
+ "/" + api_name.to_s \
+ "/" + method.public_name
end
xm.soap(:operation, 'soapAction' => soap_action)
xm.soap(:operation, 'action_web_service/soapAction' => soap_action)
xm.input do
xm.soap(:body,
'use' => 'encoded',
Expand Down
5 changes: 4 additions & 1 deletion lib/action_web_service/protocol/abstract.rb
@@ -1,3 +1,6 @@
require 'action_dispatch'
require 'action_controller'

module ActionWebService # :nodoc:
module Protocol # :nodoc:
class ProtocolError < ActionWebServiceError # :nodoc:
Expand Down Expand Up @@ -71,7 +74,7 @@ def initialize(body, content_type, return_value)
end
end

class SimpleActionPackRequest < ActionController::Request # :nodoc:
class SimpleActionPackRequest < ActionDispatch::Request # :nodoc:
def initialize(env = {})
@env = env
@qparams = {}
Expand Down
2 changes: 1 addition & 1 deletion lib/action_web_service/protocol/soap_protocol.rb
@@ -1,5 +1,5 @@
require 'action_web_service/protocol/soap_protocol/marshaler'
require 'soap/streamHandler'
require 'action_web_service/soap/streamHandler'
require 'action_web_service/client/soap_client'

module ActionWebService # :nodoc:
Expand Down
2 changes: 1 addition & 1 deletion lib/action_web_service/protocol/soap_protocol/marshaler.rb
@@ -1,4 +1,4 @@
require 'soap/mapping'
require 'action_web_service/soap/mapping'

# hack to improve the .Net interoperability
class SOAP::Mapping::Object
Expand Down
107 changes: 107 additions & 0 deletions lib/action_web_service/soap/attachment.rb
@@ -0,0 +1,107 @@
# soap/attachment.rb: SOAP4R - SwA implementation.
# Copyright (C) 2002, 2003 Jamie Herre and NAKAMURA, Hiroshi <nahi@ruby-lang.org>.

# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
# redistribute it and/or modify it under the same terms of Ruby's license;
# either the dual license version in 2003, or any later version.


require 'action_web_service/soap/baseData'
require 'action_web_service/soap/mapping'


module SOAP


class SOAPAttachment < SOAPExternalReference
attr_reader :data

def initialize(value)
super()
@data = value
end

private

def external_contentid
@data.contentid
end
end


class Attachment
attr_reader :io
attr_accessor :contenttype

def initialize(string_or_readable = nil)
@string_or_readable = string_or_readable
@contenttype = "application/octet-stream"
@contentid = nil
end

def contentid
@contentid ||= Attachment.contentid(self)
end

def contentid=(contentid)
@contentid = contentid
end

def mime_contentid
'<' + contentid + '>'
end

def content
if @content == nil and @string_or_readable != nil
@content = @string_or_readable.respond_to?(:read) ?
@string_or_readable.read : @string_or_readable
end
@content
end

def to_s
content
end

def write(out)
out.write(content)
end

def save(filename)
File.open(filename, "wb") do |f|
write(f)
end
end

def self.contentid(obj)
# this needs to be fixed
[obj.__id__.to_s, Process.pid.to_s].join('.')
end

def self.mime_contentid(obj)
'<' + contentid(obj) + '>'
end
end


module Mapping
class AttachmentFactory < SOAP::Mapping::Factory
def obj2soap(soap_class, obj, info, map)
soap_obj = soap_class.new(obj)
mark_marshalled_obj(obj, soap_obj)
soap_obj
end

def soap2obj(obj_class, node, info, map)
obj = node.data
mark_unmarshalled_obj(node, obj)
return true, obj
end
end

DefaultRegistry.add(::SOAP::Attachment, ::SOAP::SOAPAttachment,
AttachmentFactory.new, nil)
end


end

0 comments on commit a008d49

Please sign in to comment.