Exporting map containing WMS layers from outside domain to PNG image fails

1866
0
11-16-2012 01:38 AM
EvaDienske
New Contributor II
We have built a Silverlight app (2.4 API on IIS7) that is capable of exporting the visible map extent including all map layers and graphiclayers to a PNG image. To do this, we export the Grid the map is in to a WritableBitmap, like this:

        private static byte[] GridToByteArray(UIElement grid)
        {
           var writeableBitmap = new WriteableBitmap(grid, null);
            writeableBitmap.Invalidate();
            var pngStream = Encode(writeableBitmap);
            var printBuffer = new Byte[pngStream.Length];
            pngStream.Read(printBuffer, 0, printBuffer.Length);
            return printBuffer;
        }

The Encode() function uses PngEncoder.cs which is applied unmodified from http://slextensions.codeplex.com/.

This works well, provided that all layers from outside the domain go through a Proxy.ashx. If we don't use a Proxy, we get a "WriteableBitmap has protected content. Pixel access is not allowed" error. The proxy.ashx we use is unmodified from http://resources.esri.com/help/9.3/arcgisserver/apis/javascript/arcgis/help/jshelp_start.htm#jshelp/.... Its Proxy.config file has of course been modified to use the <ServerUrls> we need.

So far this solution works well with ArcGIS Tiled and Dynamic layers from outside of the domain. The trouble is that we want to use WMS layers as well. I can't get this to work with the Proxy. if I add e.g. the serverUrl

<serverUrl url="http://geoservices.rijkswaterstaat.nl/nwb_wegen?" matchAll="true"></serverUrl>

The layer displays fine when going through the proxy:

<esri:WmsLayer ID="NWB Wegen" Url="http://geoservices.rijkswaterstaat.nl/nwb_wegen?" SkipGetCapabilities="False" Layers="AAA64" Version="1.1.1" ProxyUrl="http://localhost/Proxy/proxy.ashx" />

But when exporting, this layer continues to give the "WriteableBitmap has protected content. Pixel access is not allowed" error.

Does the Proxy.ashx need to be modified to allow for this? If so, how? Is the Proxy.config OK like this? Is it even possible??

Thanks in advance,
Eva
0 Kudos
0 Replies