| 1 |
# WSDL4R - WSDL bound operation definition. |
|---|
| 2 |
# Copyright (C) 2000-2007 NAKAMURA, Hiroshi <nahi@ruby-lang.org>. |
|---|
| 3 |
|
|---|
| 4 |
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can |
|---|
| 5 |
# redistribute it and/or modify it under the same terms of Ruby's license; |
|---|
| 6 |
# either the dual license version in 2003, or any later version. |
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
require 'wsdl/info' |
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
module WSDL |
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
class OperationBinding < Info |
|---|
| 16 |
attr_reader :name # required |
|---|
| 17 |
attr_reader :input |
|---|
| 18 |
attr_reader :output |
|---|
| 19 |
attr_reader :fault |
|---|
| 20 |
attr_reader :soapoperation |
|---|
| 21 |
|
|---|
| 22 |
class BoundId |
|---|
| 23 |
attr_reader :name |
|---|
| 24 |
attr_reader :soapaction |
|---|
| 25 |
|
|---|
| 26 |
def initialize(name, soapaction) |
|---|
| 27 |
@name = name |
|---|
| 28 |
@soapaction = soapaction |
|---|
| 29 |
end |
|---|
| 30 |
|
|---|
| 31 |
def ==(rhs) |
|---|
| 32 |
!rhs.nil? and @name == rhs.name and @soapaction == rhs.soapaction |
|---|
| 33 |
end |
|---|
| 34 |
|
|---|
| 35 |
def eql?(rhs) |
|---|
| 36 |
(self == rhs) |
|---|
| 37 |
end |
|---|
| 38 |
|
|---|
| 39 |
def hash |
|---|
| 40 |
@name.hash ^ @soapaction.hash |
|---|
| 41 |
end |
|---|
| 42 |
end |
|---|
| 43 |
|
|---|
| 44 |
def initialize |
|---|
| 45 |
super |
|---|
| 46 |
@name = nil |
|---|
| 47 |
@input = nil |
|---|
| 48 |
@output = nil |
|---|
| 49 |
@fault = [] |
|---|
| 50 |
@soapoperation = nil |
|---|
| 51 |
end |
|---|
| 52 |
|
|---|
| 53 |
def targetnamespace |
|---|
| 54 |
parent.targetnamespace |
|---|
| 55 |
end |
|---|
| 56 |
|
|---|
| 57 |
def porttype |
|---|
| 58 |
root.porttype(parent.type) |
|---|
| 59 |
end |
|---|
| 60 |
|
|---|
| 61 |
def boundid |
|---|
| 62 |
BoundId.new(name, soapaction) |
|---|
| 63 |
end |
|---|
| 64 |
|
|---|
| 65 |
def find_operation |
|---|
| 66 |
porttype.operations.each do |op| |
|---|
| 67 |
next if op.name != @name |
|---|
| 68 |
next if op.input and @input and op.input.name and @input.name and |
|---|
| 69 |
op.input.name != @input.name |
|---|
| 70 |
next if op.output and @output and op.output.name and @output.name and |
|---|
| 71 |
op.output.name != @output.name |
|---|
| 72 |
return op |
|---|
| 73 |
end |
|---|
| 74 |
raise RuntimeError.new("#{@name} not found") |
|---|
| 75 |
end |
|---|
| 76 |
|
|---|
| 77 |
def soapoperation_name |
|---|
| 78 |
op_name = find_operation.operationname |
|---|
| 79 |
if @input and @input.soapbody and @input.soapbody.namespace |
|---|
| 80 |
op_name = XSD::QName.new(@input.soapbody.namespace, op_name.name) |
|---|
| 81 |
end |
|---|
| 82 |
op_name |
|---|
| 83 |
end |
|---|
| 84 |
|
|---|
| 85 |
def soapoperation_style |
|---|
| 86 |
style = nil |
|---|
| 87 |
if @soapoperation |
|---|
| 88 |
style = @soapoperation.operation_style |
|---|
| 89 |
elsif parent.soapbinding |
|---|
| 90 |
style = parent.soapbinding.style |
|---|
| 91 |
else |
|---|
| 92 |
raise TypeError.new("operation style definition not found") |
|---|
| 93 |
end |
|---|
| 94 |
style || :document |
|---|
| 95 |
end |
|---|
| 96 |
|
|---|
| 97 |
def soapbody_use_input |
|---|
| 98 |
soapbody_use(@input) |
|---|
| 99 |
end |
|---|
| 100 |
|
|---|
| 101 |
def soapbody_use_output |
|---|
| 102 |
soapbody_use(@output) |
|---|
| 103 |
end |
|---|
| 104 |
|
|---|
| 105 |
def soapaction |
|---|
| 106 |
if @soapoperation |
|---|
| 107 |
@soapoperation.soapaction |
|---|
| 108 |
else |
|---|
| 109 |
nil |
|---|
| 110 |
end |
|---|
| 111 |
end |
|---|
| 112 |
|
|---|
| 113 |
def parse_element(element) |
|---|
| 114 |
case element |
|---|
| 115 |
when InputName |
|---|
| 116 |
o = Param.new |
|---|
| 117 |
@input = o |
|---|
| 118 |
o |
|---|
| 119 |
when OutputName |
|---|
| 120 |
o = Param.new |
|---|
| 121 |
@output = o |
|---|
| 122 |
o |
|---|
| 123 |
when FaultName |
|---|
| 124 |
o = Param.new |
|---|
| 125 |
@fault << o |
|---|
| 126 |
o |
|---|
| 127 |
when SOAPOperationName |
|---|
| 128 |
o = WSDL::SOAP::Operation.new |
|---|
| 129 |
@soapoperation = o |
|---|
| 130 |
o |
|---|
| 131 |
when DocumentationName |
|---|
| 132 |
o = Documentation.new |
|---|
| 133 |
o |
|---|
| 134 |
else |
|---|
| 135 |
nil |
|---|
| 136 |
end |
|---|
| 137 |
end |
|---|
| 138 |
|
|---|
| 139 |
def parse_attr(attr, value) |
|---|
| 140 |
case attr |
|---|
| 141 |
when NameAttrName |
|---|
| 142 |
@name = value.source |
|---|
| 143 |
else |
|---|
| 144 |
nil |
|---|
| 145 |
end |
|---|
| 146 |
end |
|---|
| 147 |
|
|---|
| 148 |
private |
|---|
| 149 |
|
|---|
| 150 |
def soapbody_use(param) |
|---|
| 151 |
param ? param.soapbody_use : nil |
|---|
| 152 |
end |
|---|
| 153 |
end |
|---|
| 154 |
|
|---|
| 155 |
|
|---|
| 156 |
end |
|---|