source: extensions/gsdl-video/trunk/installed/cmdline/lib/ruby/1.8/wsdl/soap/operation.rb@ 18425

Last change on this file since 18425 was 18425, checked in by davidb, 15 years ago

Video extension to Greenstone

File size: 2.7 KB
Line 
1# WSDL4R - WSDL SOAP operation definition.
2# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <[email protected]>.
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
9require 'wsdl/info'
10
11
12module WSDL
13module SOAP
14
15
16class Operation < Info
17 class OperationInfo
18 attr_reader :style
19 attr_reader :op_name
20 attr_reader :optype_name
21 attr_reader :headerparts
22 attr_reader :bodyparts
23 attr_reader :faultpart
24 attr_reader :soapaction
25
26 def initialize(style, op_name, optype_name, headerparts, bodyparts, faultpart, soapaction)
27 @style = style
28 @op_name = op_name
29 @optype_name = optype_name
30 @headerparts = headerparts
31 @bodyparts = bodyparts
32 @faultpart = faultpart
33 @soapaction = soapaction
34 end
35 end
36
37 attr_reader :soapaction
38 attr_reader :style
39
40 def initialize
41 super
42 @soapaction = nil
43 @style = nil
44 end
45
46 def parse_element(element)
47 nil
48 end
49
50 def parse_attr(attr, value)
51 case attr
52 when StyleAttrName
53 if ["document", "rpc"].include?(value.source)
54 @style = value.source.intern
55 else
56 raise Parser::AttributeConstraintError.new(
57 "Unexpected value #{ value }.")
58 end
59 when SOAPActionAttrName
60 @soapaction = value.source
61 else
62 nil
63 end
64 end
65
66 def input_info
67 name_info = parent.find_operation.input_info
68 param_info(name_info, parent.input)
69 end
70
71 def output_info
72 name_info = parent.find_operation.output_info
73 param_info(name_info, parent.output)
74 end
75
76 def operation_style
77 return @style if @style
78 if parent_binding.soapbinding
79 return parent_binding.soapbinding.style
80 end
81 nil
82 end
83
84private
85
86 def parent_binding
87 parent.parent
88 end
89
90 def param_info(name_info, param)
91 op_name = name_info.op_name
92 optype_name = name_info.optype_name
93
94 soapheader = param.soapheader
95 headerparts = soapheader.collect { |item| item.find_part }
96
97 soapbody = param.soapbody
98 if soapbody.encodingstyle and
99 soapbody.encodingstyle != ::SOAP::EncodingNamespace
100 raise NotImplementedError.new(
101 "EncodingStyle '#{ soapbody.encodingstyle }' not supported.")
102 end
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
115 faultpart = nil
116 OperationInfo.new(operation_style, op_name, optype_name, headerparts, bodyparts, faultpart, parent.soapaction)
117 end
118end
119
120
121end
122end
Note: See TracBrowser for help on using the repository browser.