[Ironruby-core] IronRuby and MarkLogic

Eric Nicholson enicholson at gmail.com
Thu Nov 29 11:29:56 EST 2007


I think instead of
   $content_source::NewSession()

you want
   $content_source.NewSession()

:: is a scoping operator.

-Eric

On Nov 29, 2007 10:00 AM, N. F. <lists at ruby-forum.com> wrote:

> 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: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=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:admin@localhost:9003') # help from
> John Lam 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!
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Ironruby-core mailing list
> Ironruby-core at rubyforge.org
> http://rubyforge.org/mailman/listinfo/ironruby-core
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20071129/1e2c19c7/attachment.html 


More information about the Ironruby-core mailing list