WMS problems with 10.1 and Proxy files

2116
1
06-07-2013 06:03 AM
ErnieSalazar
New Contributor III
Hi Everyone.  We finally upgraded to AGS 10.1 and are switching over our web services.  One issue I am running into is using the layers as WMS with a Proxy file (one of many error actually but I have gotten around the others).  Using SL 5 and version 3.1 of the API (also tried this with SL 4 and api 3.0 but upgraded to see if it made a difference).

Prior to 10.1, I had a bunch of different layer types load in our SL app - Dynamic, Tiled and WMS.  Also had a proxy file sitting on the same server in the the app (ie ./Proxy/proxy.ashx and proxy.config).  Everything worked fine, I added url stems to the proxy file with a match all set.  So for example:

<serverItem url="http://serverx/" matchAll="true" />


In this case the layer did not have security turned on but we have to add an entry for it anyway - which worked fine.  Now, with 10.1, I keep getting a "not found" error bounce back from the WMS layer.  I tried adjusting for the port with something like this but no dice:

<serverItem url="http://serverx:6080/" matchAll="true" />


Fidder comes back with this:



Non-negative number required.
Parameter name: count
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentOutOfRangeException: Non-negative number required.
Parameter name: count

Source Error:

Line 108:            {
Line 109:                BinaryReader br = new BinaryReader(byteStream);
Line 110:                byte[] outb = br.ReadBytes((int)serverResponse.ContentLength);
Line 111:                br.Close();
Line 112:

Source File: c:\....\Proxy\proxy.ashx    Line: 110

Stack Trace:
[ArgumentOutOfRangeException: Non-negative number required.
Parameter name: count]
   System.IO.BinaryReader.ReadBytes(Int32 count) +14387194
   proxy.ProcessRequest(HttpContext context) in c:\....l\Proxy\proxy.ashx:110
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +913
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165



If I disable the code that sets t he Proxy in the WMSLayer.ProxyUrl property everything works fine.   Any insight?

Thanks
Ernie
0 Kudos
1 Reply
DominiqueBroux
Esri Frequent Contributor
It seems the issue is in your proxy. You can't rely on the ContentLength that may be equals to -1.

I would suggest code like:
               BinaryReader br = new BinaryReader(byteStream);
                int length = (int)serverResponse.ContentLength;
                if (length < 0) length = 10000000;
                byte[] outb = br.ReadBytes(length);
                br.Close();