-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first short at following wsdl imports
this required a pretty major re-architecture and we're not even done.
- Loading branch information
Showing
29 changed files
with
948 additions
and
322 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
require 'uri' | ||
|
||
class Wasabi | ||
class DocumentCollection | ||
include Enumerable | ||
|
||
def initialize | ||
@documents = [] | ||
end | ||
|
||
def <<(document) | ||
@documents << document | ||
end | ||
|
||
def each(&block) | ||
@documents.each(&block) | ||
end | ||
|
||
def service_name | ||
@service_name ||= first.service_name | ||
end | ||
|
||
def target_namespace | ||
@target_namespace ||= first.target_namespace | ||
end | ||
|
||
def target_namespace | ||
@target_namespace ||= first.target_namespace | ||
end | ||
|
||
def namespaces | ||
@namespaces ||= inject({}) { |memo, document| memo.merge(document.namespaces) } | ||
end | ||
|
||
def operations | ||
@operations ||= inject({}) { |memo, document| memo.merge(document.operations) } | ||
end | ||
|
||
# TODO: this works for now, but it should be moved into the Operation, | ||
# because there can be different endpoints for different operations. | ||
def endpoint | ||
return @endpoint if @endpoint | ||
|
||
if service = first.service_node | ||
endpoint = service.at_xpath(".//soap11:address/@location", 'soap11' => Wasabi::SOAP_1_1) | ||
endpoint ||= service.at_xpath(service_node, ".//soap12:address/@location", 'soap12' => Wasabi::SOAP_1_2) | ||
end | ||
|
||
begin | ||
@endpoint = URI(URI.escape(endpoint.to_s)) if endpoint | ||
rescue URI::InvalidURIError | ||
@endpoint = nil | ||
end | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
require 'nokogiri' | ||
require 'wasabi/document' | ||
require 'wasabi/document_collection' | ||
require 'wasabi/schema_collection' | ||
|
||
class Wasabi | ||
class Importer | ||
|
||
def initialize(resolver, wsdl) | ||
@resolver = resolver | ||
@wsdl = wsdl | ||
end | ||
|
||
def import(location) | ||
documents = DocumentCollection.new | ||
schemas = SchemaCollection.new | ||
|
||
import! [location] do |document| | ||
documents << document | ||
schemas.push(document.schemas) | ||
end | ||
|
||
[documents, schemas] | ||
end | ||
|
||
private | ||
|
||
def import!(locations, &block) | ||
locations.each do |location| | ||
xml = @resolver.resolve(location) | ||
document = Document.new Nokogiri.XML(xml), @wsdl | ||
|
||
block.call(document) | ||
|
||
import! document.imports, &block | ||
end | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.