| 1 |
# WSDL4R - WSDL SOAP 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 |
module SOAP |
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
class Operation < Info |
|---|
| 17 |
class OperationInfo |
|---|
| 18 |
attr_reader :style |
|---|
| 19 |
attr_reader :op_name |
|---|
| 20 |
attr_reader :optype_name |
|---|
| 21 |
attr_reader :encodingstyle |
|---|
| 22 |
attr_reader :headerparts |
|---|
| 23 |
attr_reader :bodyparts |
|---|
| 24 |
attr_reader :faultpart |
|---|
| 25 |
attr_reader :soapaction |
|---|
| 26 |
|
|---|
| 27 |
def initialize(style, use, encodingstyle, op_name, optype_name, |
|---|
| 28 |
headerparts, bodyparts, faultpart, soapaction) |
|---|
| 29 |
@style = style |
|---|
| 30 |
@use = use |
|---|
| 31 |
@encodingstyle = encodingstyle |
|---|
| 32 |
@op_name = op_name |
|---|
| 33 |
@optype_name = optype_name |
|---|
| 34 |
@headerparts = headerparts |
|---|
| 35 |
@bodyparts = bodyparts |
|---|
| 36 |
@faultpart = faultpart |
|---|
| 37 |
@soapaction = soapaction |
|---|
| 38 |
end |
|---|
| 39 |
end |
|---|
| 40 |
|
|---|
| 41 |
attr_reader :soapaction |
|---|
| 42 |
attr_reader :style |
|---|
| 43 |
|
|---|
| 44 |
def initialize |
|---|
| 45 |
super |
|---|
| 46 |
@soapaction = nil |
|---|
| 47 |
@style = nil |
|---|
| 48 |
end |
|---|
| 49 |
|
|---|
| 50 |
def parse_element(element) |
|---|
| 51 |
nil |
|---|
| 52 |
end |
|---|
| 53 |
|
|---|
| 54 |
def parse_attr(attr, value) |
|---|
| 55 |
case attr |
|---|
| 56 |
when StyleAttrName |
|---|
| 57 |
if ["document", "rpc"].include?(value.source) |
|---|
| 58 |
@style = value.source.intern |
|---|
| 59 |
else |
|---|
| 60 |
raise Parser::AttributeConstraintError.new( |
|---|
| 61 |
"Unexpected value #{ value }.") |
|---|
| 62 |
end |
|---|
| 63 |
when SOAPActionAttrName |
|---|
| 64 |
@soapaction = value.source |
|---|
| 65 |
else |
|---|
| 66 |
nil |
|---|
| 67 |
end |
|---|
| 68 |
end |
|---|
| 69 |
|
|---|
| 70 |
def input_info |
|---|
| 71 |
name_info = parent.find_operation.input_info |
|---|
| 72 |
param_info(name_info, parent.input) |
|---|
| 73 |
end |
|---|
| 74 |
|
|---|
| 75 |
def output_info |
|---|
| 76 |
name_info = parent.find_operation.output_info |
|---|
| 77 |
param_info(name_info, parent.output) |
|---|
| 78 |
end |
|---|
| 79 |
|
|---|
| 80 |
def operation_style |
|---|
| 81 |
return @style if @style |
|---|
| 82 |
if parent_binding.soapbinding |
|---|
| 83 |
return parent_binding.soapbinding.style |
|---|
| 84 |
end |
|---|
| 85 |
nil |
|---|
| 86 |
end |
|---|
| 87 |
|
|---|
| 88 |
private |
|---|
| 89 |
|
|---|
| 90 |
def parent_binding |
|---|
| 91 |
parent.parent |
|---|
| 92 |
end |
|---|
| 93 |
|
|---|
| 94 |
def param_info(name_info, param) |
|---|
| 95 |
op_style = operation_style() |
|---|
| 96 |
op_use = param.soapbody_use |
|---|
| 97 |
op_encodingstyle = param.soapbody_encodingstyle |
|---|
| 98 |
op_name = name_info.op_name |
|---|
| 99 |
optype_name = name_info.optype_name |
|---|
| 100 |
soapheader = param.soapheader |
|---|
| 101 |
headerparts = soapheader.collect { |item| item.find_part } |
|---|
| 102 |
soapbody = param.soapbody |
|---|
| 103 |
if soapbody.namespace |
|---|
| 104 |
op_name = XSD::QName.new(soapbody.namespace, op_name.name) |
|---|
| 105 |
end |
|---|
| 106 |
if soapbody.parts |
|---|
| 107 |
target = soapbody.parts.split(/\s+/) |
|---|
| 108 |
bodyparts = name_info.parts.find_all { |part| |
|---|
| 109 |
target.include?(part.name) |
|---|
| 110 |
} |
|---|
| 111 |
else |
|---|
| 112 |
bodyparts = name_info.parts |
|---|
| 113 |
end |
|---|
| 114 |
faultpart = nil |
|---|
| 115 |
OperationInfo.new(op_style, op_use, op_encodingstyle, op_name, optype_name, |
|---|
| 116 |
headerparts, bodyparts, faultpart, parent.soapaction) |
|---|
| 117 |
end |
|---|
| 118 |
end |
|---|
| 119 |
|
|---|
| 120 |
|
|---|
| 121 |
end |
|---|
| 122 |
end |
|---|