[jboss-svn-commits] JBL Code SVN: r21675 - in labs/jbossrules/trunk/drools-server: sample-clients and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Aug 22 03:37:48 EDT 2008


Author: michael.neale at jboss.com
Date: 2008-08-22 03:37:48 -0400 (Fri, 22 Aug 2008)
New Revision: 21675

Added:
   labs/jbossrules/trunk/drools-server/sample-clients/
   labs/jbossrules/trunk/drools-server/sample-clients/ruby_json.rb
Log:
sample ruby client

Added: labs/jbossrules/trunk/drools-server/sample-clients/ruby_json.rb
===================================================================
--- labs/jbossrules/trunk/drools-server/sample-clients/ruby_json.rb	                        (rev 0)
+++ labs/jbossrules/trunk/drools-server/sample-clients/ruby_json.rb	2008-08-22 07:37:48 UTC (rev 21675)
@@ -0,0 +1,24 @@
+# @author Michael Neale
+# Was tested in rails 2.1
+
+    require 'json'
+    http = Net::HTTP.new('localhost', 8080)
+    path = "/drools-server/knowledgebase/teamallocation"
+    post_data = {"knowledgebase-request" => {                     
+                  :globals => {"named-fact" => [{:id => "a", :fact => {"@class" => "teamallocation.Assignment"}}]},
+                  :inFacts => {"anon-fact" => [{:fact => {"@class" => "teamallocation.Claim", "value" => 150}}]},
+                  :inOutFacts => {"named-fact" => [{:id => "x", :fact => {"@class" => "teamallocation.Team", "specialty" => "FATAL"}},
+                                                   {:id => "y", :fact => {"@class" => "teamallocation.Team"}}]}
+                                            }                    
+                 }
+    headers = {
+      "Content-Type" => "application/json"
+    }
+    resp, data = http.post(path, post_data.to_json, headers)
+    
+    
+    answer = JSON.parse(data)
+    #digging out the results:
+    puts answer["knowledgebase-response"]["globals"]["named-fact"]["fact"]["teamName"]
+    #if there is more then one fact, they are a list
+    puts answer["knowledgebase-response"]["inOutFacts"]["named-fact"][0]["fact"]["specialty"]


Property changes on: labs/jbossrules/trunk/drools-server/sample-clients/ruby_json.rb
___________________________________________________________________
Name: svn:eol-style
   + native




More information about the jboss-svn-commits mailing list