Hello,
I would like to enumerate all resources but I get an Exception everytime I try to get a MgResourceService object:
"org.osgeo.mapguide.MgServiceNotSupportedException: The specified service is not supported."
But when I browse MapAgent ( Services API > "Resources" > "EnumerateResources"), I can retrieve the resources.
Here the source code I'm using:
----------------------------------------------
{code}
MapGuideJavaApi.MgInitializeWebTier("C:\\Program Files\\MapGuideOpenSource2.0\\Server\\Bin\\serverconfig.ini");
MgUserInformation cred = new MgUserInformation("Administrator", "admin");
// Connect to the site and get a feature service and a resource service instances
MgSiteConnection siteConn = new MgSiteConnection();
siteConn.Open(cred);
// Create a session repository
MgSite site = siteConn.GetSite();
sessionId = site.CreateSession();
// >>>> THE EXCEPTION OCCURS AT THE FOLLOWING LINE <<<<
MgResourceService resourceSrvc = (MgResourceService)siteConn.CreateService(MgServiceType.ResourceService);
// Enumerates all maps in the library
MgResourceIdentifier resourceId = new MgResourceIdentifier("Library://");
MgByteReader mgBR = resourceSrvc.EnumerateResources(resourceId, -1, "MapDefinition", false);
System.out.println("-------------------------MAPS----------------------------");
System.out.println(mgBR.toString());
System.out.println("---------------------------------------------------------");
}
catch(MgException mge)
{
mge.printStackTrace();
}
{code}
----------------------------------------------
I checked in MapAdmin if the service was well set... but I have seen nothing wrong.
Thanks to post a suggestion if you have an little idea.
Edited by: kdelcroix on Feb 17, 2009 10:40 AM
Added "code" tags
Edited by: kdelcroix on Feb 17, 2009 10:41 AM
Better visibility of the line generating the error