SOLVED: minimal ruby mapserver GetCapabilities (was Re: [UMN_MAPSERVER-USERS] ruby mapscript: bug in Makefile + GetCapabilities return zlitch !)

s duclos sylvain_duclos at YAHOO.COM
Tue Jul 11 13:16:38 EDT 2006


Hi,

I'm following up on myself for googlers .. 

Bellow is a minimal WMS/mapserver in ruby
that send back to the browser the capabilities
of the WMS server. No .map or any other config.
It work in OpenEV also.


Cheers,

Sylvain.



-------------------->8------------------------------
#!/usr/bin/ruby

require 'webrick'
include WEBrick

require "mapscript"
include Mapscript

WMS_proc = lambda do |req, resp|
  resp['Content-Type'] = "text/xml"

  map = MapObj.new()
  map.setMetaData( "ows_onlineresource",
"http://dummy.org/" )

  wxsReq = OWSRequest.new()
  wxsReq.setParameter("SERVICE", "WMS")
  wxsReq.setParameter("VERSION", "1.1.1")
  wxsReq.setParameter("REQUEST", "GetCapabilities")

  msIO_installStdoutToBuffer()
  ret = map.OWSDispatch(wxsReq)
  resp.body = msIO_getStdoutBufferBytes().to_s
end

WMS = HTTPServlet::ProcHandler.new(WMS_proc)

s = HTTPServer.new(:Port => 2000)
s.mount("/WMS",   WMS)

trap("INT"){ s.shutdown }
s.start
-------------------->8------------------------------






--- s duclos <sylvain_duclos at YAHOO.COM> wrote:

> Hi,
> 
> I tried to reach:
> Markus Schnider
> msr at sourcepole.ch 
> http://www.sourcepole.com 
> 
> but it seem that he is not there anymore
> 
> any way the makefile need to have ruby.h defines.h
> commented
> for the build to work
> 
> #$(OBJS): ruby.h defines.h
> mapscript_wrap.c: ../mapscript.i
>         swig -ruby -o mapscript_wrap.c
> ../mapscript.i
> 
> 
> 
> 
> 
> 
> 
> Also I'm trying to get very basic stuff out of
> mapserv
> (GetCapabilities)
> 
> --------------------------------------------
>   map = MapObj.new()
>   map.setMetaData( "ows_onlineresource",
> "http://dummy.org/" )
>   
>   wxsReq = OWSRequest.new()
>   wxsReq.setParameter("SERVICE", "WMS")
>   wxsReq.setParameter("VERSION", "1.1.1")
>   wxsReq.setParameter("REQUEST", "GetCapabilities")
> 
>   msIO_installStdoutToBuffer()
> 
>   ret = map.OWSDispatch(wxsReq)
>   p ret
>   p MS_SUCCESS
> 
>   p msIO_getStdoutBufferString()
>   p msIO_getStdoutBufferBytes()
> 
>   print
> "============WMS_req-req=====================\n"
>   resp.body = req.to_s
>   print "#{req}"
>   print
> "==========================================\n"
> ---------------------------------------------
> 
> 
> and this is what I get from webrick
> 
> ----------------------------------------------
> 2
> 0
> ""
> ""
> ============WMS_req-req=====================
> GET /WMS HTTP/1.1WxSTest.java WxSTest.java
> Host: s5-imar:2000
> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1;
> en-US; rv:1.8.0.4) Gecko/20060508 Firefox/1.5.0.4
> Accept:
>
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
> Accept-Language: en-us,en;q=0.5
> Accept-Encoding: gzip,deflate
> Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
> Keep-Alive: 300
> Connection: keep-alive
> Cache-Control: max-age=0
> 
> ============================================
> 172.23.64.165 - - [09/Jul/2006:08:20:31 EDT] "GET
> /WMS
> HTTP/1.1" 200 433
> - -> /WMS
> -------------------------------------------
> 
> 
> 
> 
> I tried from the shell and it work OK, now I would
> like to do the same from ruby so that
> I can return GetCapabilities to OpenEV.
> 
> 
> Any hint!
> 
> 
> thxs,
> 
> Sylvain.
> 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam
> protection around 
> http://mail.yahoo.com 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the mapserver-users mailing list