[mapguide-users] Storing WebLayout in Session Repository
Hidekazu Shimaji
hshimaji at ybb.ne.jp
Wed Feb 21 09:51:14 EST 2007
Hello,
I don't think the ResourceHeader is the cause.
You have to set the content of xmlWebLayout to byteArray.
How about do like this:
--- the code start
//save the xml to MemoryStream
System.IO.MemoryStream stream = new System.IO.MemoryStream();
xmlWebLayout.Save(stream);
// get byte array from the MemoryStream
byte[] byteArray = stream.ToArray();
//convert byte array to string without the first byte(BOM)
string outerXml = System.Text.Encoding.UTF8.GetString(byteArray, 1, byteArray.Length - 1);
// convert string to byte array with the utf-8 encoding
byteArray = System.Text.Encoding.UTF8.GetBytes(outerXml);
// store the WebLayout in Session-Repository
MgByteSource byteSource = new MgByteSource(byteArray,
byteArray.Length);
byteSource.MimeType = MgMimeType.Xml;
MgResourceIdentifier userWebLayoutId = new
MgResourceIdentifier("Session:" + sessionId + @"//Current." +
MgResourceType.WebLayout);
resourceService.SetResource(userWebLayoutId, byteSource.GetReader(), null);
--- the code end
Do you have the MapGuide sample for .NET?
It is downloadable from the MapGuide web site,
and the code "findaddressfunctions.aspx" has some good examples
for using the SetResource function.
Try it!
Regards,
Hidekazu Shimaji
--- Gunter Becker <gunter.becker at CSOGIS.DE> wrote:
>
> Hi all,
>
> I'm trying to store a modyfied WebLayout in the users "Session-Repository"
> with the following code (same as in Devolper's Guide, page 70, "Making
> Changes Permanent"):
>
> // get the XMLDocument as byte-array
> byte[] byteArray = new byte[xmlWebLayout.OuterXml.Length];
>
> // store the WebLayout in Session-Repository
> MgByteSource byteSource = new MgByteSource(byteArray,
> byteArray.Length);
> byteSource.MimeType = MgMimeType.Xml;
> MgResourceIdentifier userWebLayoutId = new
> MgResourceIdentifier("Session:" + MgSessionId + @"//Current." +
> MgResourceType.WebLayout);
>
> resourceService.SetResource(userWebLayoutId,byteSource.GetReader(),null);
>
> When executing the last line of the code I get the error massage:
>
> Argument is null. Exception occurred in method
> MgResourceContentManager.AddResource at line 153 in file
>
c:\build_bond_area\mapguide_open_source\build_3.1\mgdev\server\src\services\resource\ResourceContentManager.cpp
>
> Maybe the null-value for the ResourceHeader isn't correct when storing a
> WebLayout. How can I get a ResourceHeader for that Resource. Is it possible
> to store a WebLayout in a Session-Repository at all????
>
> When using the "SetResource"-Operation manually through the "Web Tier Test"
> and place current ResourceId and the users Session-Repository and leave the
> Header-Textbox blank then it works fine. After that I'm able to get the
> AjaxViewer show the modyfied WebLayout.
>
> Hope that somebody can help me out of this.
>
> Thanks in advance,
>
> Gunter
> --
> View this message in context:
> http://www.nabble.com/Storing-WebLayout-in-Session-Repository-tf3265925s16610.html#a9078585
> Sent from the MapGuide Users mailing list archive at Nabble.com.
>
> _______________________________________________
> mapguide-users mailing list
> mapguide-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>
More information about the mapguide-users
mailing list