lib/ruby_odata/service.rb in ruby_odata-0.1.5 vs lib/ruby_odata/service.rb in ruby_odata-0.1.6
- old
+ new
@@ -294,11 +294,22 @@
# Parses the function imports and fills the @function_imports collection
def build_function_imports
# Fill in the function imports
functions = @edmx.xpath("//edm:EntityContainer/edm:FunctionImport", @ds_namespaces)
functions.each do |f|
- http_method = f.xpath("@m:HttpMethod", @ds_namespaces).first.content
+ http_method_attribute = f.xpath("@m:HttpMethod", @ds_namespaces).first # HttpMethod is no longer required http://www.odata.org/2011/10/actions-in-odata/
+ is_side_effecting_attribute = f.xpath("@edm:IsSideEffecting", @ds_namespaces).first
+
+ http_method = 'POST' # default to POST
+
+ if http_method_attribute
+ http_method = http_method_attribute.content
+ elsif is_side_effecting_attribute
+ is_side_effecting = is_side_effecting_attribute.content
+ http_method = is_side_effecting ? 'POST' : 'GET'
+ end
+
return_type = f["ReturnType"]
inner_return_type = nil
unless return_type.nil?
return_type = (return_type =~ /^Collection/) ? Array : convert_to_local_type(return_type)
if f["ReturnType"] =~ /\((.*)\)/
@@ -366,10 +377,14 @@
raise e unless defined? e.response
code = e.http_code
error = Nokogiri::XML(e.response)
- message = error.xpath("m:error/m:message", @ds_namespaces).first.content
+ message = if error.xpath("m:error/m:message", @ds_namespaces).first
+ error.xpath("m:error/m:message", @ds_namespaces).first.content
+ else
+ "Server returned error but no message."
+ end
raise ServiceError.new(code), message
end
# Loops through the standard properties (non-navigation) for a given class and returns the appropriate list of methods
def collect_properties(klass_name, element, doc)