Hi,
I have used IronPython to successfully connect and issue an xquery to a
MarkLogic database (native XML database) using the following script:
import clr
clr.AddReferenceToFile(“MarklogicXcc.dll”)
import Marklogic.Xcc
import System
print ‘connecting to db…’
uri = System.Uri(‘xcc://adm:[email protected]: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=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089’
require “c:\IronRuby\build\release\MarklogicXcc.dll”
all xcc dlls have to be in the same dir as ironruby (except for
MarklogicXcc.dll)
puts ‘connecting to db…’
$uri = System::Uri.new(‘xcc://admin:[email protected]:9003’) # help from
John L. here…thanks!
$content_source =
Marklogic::Xcc::ContentSourceFactory::NewContentSource($uri)
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 #<Marklogic::Xcc::Impl::ContentSourceImpl:0x0000058>:Ruby.Builtins.RubyClass 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???
Thanks!