[mapguide-users] MgRenderingService RenderMap problem

Satu attila.sagi at geoview.hu
Wed Feb 25 11:47:40 EST 2009


Hi,

I'd like to create a web site, which is able to connect a MapGuide server,
and receive map data in png format.

I have been created an Aspx page, but I got an error at the following line: 

mySel.Open(resourceService, "Sheboygan");

Exception Details: OSGeo.MapGuide.MgSessionExpiredException: Session
expired, please login again.


What's wrong in my code? 

Please help!

Here is my code:


MapGuideApi.MgInitializeWebTier(@"C:\Program
Files\Autodesk\MapGuideEnterprise2009\WebServerExtensions\www\webconfig.ini");

MgUserInformation userInfo = new MgUserInformation("Anonymous", "");

MgSite site = new MgSite();

site.Open(userInfo);

String sessionId = site.CreateSession();

String webLayout =
"Library://Samples/Sheboygan/Layouts/SheboyganAspTiled.WebLayout";

MgSiteConnection siteConnection = new MgSiteConnection();

siteConnection.Open(userInfo);

MgResourceService resourceService =
(MgResourceService)siteConnection.CreateService(MgServiceType.ResourceService);

MgMappingService mappingService =
(MgMappingService)siteConnection.CreateService(MgServiceType.MappingService);

MgMap map = new MgMap();

MgResourceIdentifier myResID = new
MgResourceIdentifier("Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition");

map.Create(resourceService, myResID, myResID.GetName().ToString() );

MgRenderingService myRenderService =
(MgRenderingService)siteConnection.CreateService(MgServiceType.RenderingService);

MgSelection mySel = new MgSelection(map);

mySel.Open(resourceService, "Sheboygan");

MgByteReader byteReader = myRenderService.RenderMap(map, mySel, "PNG");

MgByteSink byteSink = new MgByteSink(byteReader);

string filePath = @"C:\temp\myMap.png";

byteSink.ToFile(filePath);

I use: MapGuide Enterprise 2009, IIS.

-- 
View this message in context: http://n2.nabble.com/MgRenderingService-RenderMap-problem-tp2384773p2384773.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20090225/4bfd1735/attachment.html


More information about the mapguide-users mailing list