[Ironruby-core] IronRuby and MarkLogic

N. F. lists at ruby-forum.com
Thu Nov 29 10:00:19 EST 2007


I have used IronPython to successfully connect and issue an xquery to a
MarkLogic database (native XML database) using the following script:

import clr
import Marklogic.Xcc
import System
print 'connecting to db...'
uri = System.Uri('xcc://adm:adm@localhost:9003')
contentSource = Marklogic.Xcc.ContentSourceFactory.NewContentSource(uri)
print 'creating session...'
session = contentSource.NewSession()
print 'submitting query...'
query = 'let $r := //Record[@UID eq "20069812"] return $r'
request = session.NewAdhocQuery(query)
resultSequence = session.SubmitRequest(request)
print 'printing results...'
results = resultSequence.AsString()
print results

Now, I am trying the same thing with IronRuby and here is how far I got:

require 'System, Version=, Culture=neutral,
require "c:\\IronRuby\\build\\release\\MarklogicXcc.dll"
# all xcc dlls have to be in the same dir as ironruby (except for
puts 'connecting to db...'
$uri = System::Uri.new('xcc://admin:admin@localhost:9003') # help from
John Lam here...thanks!
$content_source =
puts 'creating session...'
$session = $content_source::NewSession()

For some reason, NewSession is not seen as a valid method. Here is part
of the interpreter's output:

System.MissingMethodException: undefined local variable or method
`NewSession' for
   at Ruby.Builtins.Kernel.MethodMissing(CodeContext context, Object
self, Block
Param block, SymbolId name, Object[] args)
   at Microsoft.Scripting.Utils.InvokeHelper`6.Invoke(Object arg0,
Object arg1,
Object arg2, Object arg3, Object arg4)

The NewSession method is certainly part of the Marklogic DLL. I see it
with Object Browser in Visual Studio, I used it successfully with
IronPython above and with the production code I have, which is in C#.

To make sure that I am not getting anything funny returning to
$content_source, I tried this:
$session = Marklogic::Xcc::ContentSource::NewSession("someId")
But, still got the same error message...

Any thoughts???

Posted via http://www.ruby-forum.com/.

More information about the Ironruby-core mailing list