Select to view content in your preferred language

FeatureLayer ProxyUrl bug?

3132
11
06-25-2010 12:07 PM
BrooksShannon
Deactivated User
Hey guys,

I'm attempting to use a FeatureLayer with a proxy, and I'm having some problems.  Currently, I'm using the 2.0 public beta API, and I think the issues I'm seeing might be related to a bug, or bugs, in the API code.

If I specify that a FeatureLayer should use a proxy, like this:

<esri:FeatureLayer ID="MyFeatureLayer" 
                DisableClientCaching="True"
                Url="http://localhost/ArcGIS/rest/services/MyMapService/FeatureServer/0"
                ProxyUrl="http://localhost/MySLApp/proxy.ashx"
                Mode="OnDemand" 
                AutoSave="False"
                Color="Blue"
                OnDemandCacheSize="500"                 
                OutFields="NAME,IDENTIFIER,DLVRY_ADD"
                InitializationFailed="Layer_InitializationFailed"
                Initialized="Layer_Initialized">


I will receive the following exception, that I can capture in the layer's InitializationFailed event:

System.Net.WebException: The remote server returned an error: NotFound. ---> 
 System.Net.WebException: The remote server returned an error: NotFound.
 at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
 at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
 at System.Net.Browser.AsyncHelper.<>c__DisplayClass2.<BeginOnUI>b__0(Object sendState)
 --- End of inner exception stack trace ---
 at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
 at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
 at System.Net.WebClient.GetWebResponse(WebRequest request, IAsyncResult result)
 at System.Net.WebClient.DownloadBitsResponseCallback(IAsyncResult result)


I spent a little time poking around with Firebug, and found out the following:

1) Things like tiled layers request the proxy page at
http://localhost/MySLApp/proxy.ashx?<theUrlItWants>
The FeatureLayer, however, requests the proxy page at
http://localhost/MySLApp/proxy.ashx<theUrlItWants>
during initialization - the key difference being the missing "?".

2) Post-initialization, the FeatureLayer goes back to requesting the proxy page at
http://localhost/MySLApp/proxy.ashx?<theUrlItWants>
  The "?" is there where it should be - this time.

3) The FeatureLayer, unlike other map services, won't let me use a relative path to the proxy page.  If I try using a relative path (say, "../proxy.ashx") I receive an exception claiming the URI kind can't be determined.  I'm forced to specify an absolute path, along with the protocol.

It could very well be the case that this is resolved in the 2.0 RC API - but the download link appears broken, so I can't find out. As it stands right now, however, I can't think of any way to make this work.  I could do something like use a proxy URL of
http://localhost/MySLApp/proxy.ashx?
(adding the "?" to the end) - but that makes any of the requests that come after layer initialization bomb.  (Which is what led me to believe that it's probably just a bug in the FeatureLayer's initialization - or something that occurs internally near the time of initialization, anyways.)

Does anyone from ESRI have any information that could help in this situation?

Thanks!
Brooks
0 Kudos
11 Replies
DavidAllen-Williams
Emerging Contributor
I'm getting the same problems with the 2.0RC, so it looks like this hasn't been resolved yet..
0 Kudos
BrooksShannon
Deactivated User
I'm getting the same problems with the 2.0RC, so it looks like this hasn't been resolved yet..


Thanks for letting me know.  Does anyone from ESRI know if this will be addressed at the 2.0 release?
0 Kudos
dotMorten_esri
Esri Notable Contributor
Thanks. This will be addressed in final
0 Kudos
BrooksShannon
Deactivated User
Thanks. This will be addressed in final


Thanks!  I appreciate you letting me know.
0 Kudos
DavidAllen-Williams
Emerging Contributor
Related to this issue, the 2.0RC also does not let you use a relative url for a feature layer - for example all the following fail with
[INDENT]System.UriFormatException: Invalid URI: The format of the URI could not be determined.

<esri:FeatureLayer Url="../mapit/dbo.MyFeature" ... />
<esri:FeatureLayer Url="~/mapit/dbo.MyFeature" ... />
<esri:FeatureLayer Url="/mapit/dbo.MyFeature" ... />
<esri:FeatureLayer Url="mapit/dbo.MyFeature" ... />
[/INDENT]

Hopefully will be fixed in final too?
0 Kudos
dotMorten_esri
Esri Notable Contributor
All layer types requires an absolute URL to the service endpoint.
0 Kudos
JayOckers
Deactivated User
Is there any word on when final release will drop?
0 Kudos
JayOckers
Deactivated User
This is broken in a different way with the final release.  When no proxy is used, the request looks like this:

http://HOSTNAME/ArcGIS/rest/services/MyMapService/MapServer/5/query?...

But when a proxy is used, the request looks like this:
https://HOSTNAME/ArcGIS/rest/services/MySecureMapService/MapServer/5?...
0 Kudos
RexHansen
Esri Contributor
During initialization a FeatureLayer will send two requests.  One for metadata and another to query and return features.   If using a proxy and defining the ProxyUrl property, both requests will be redirected through the proxy.   There are two issues I discovered with the proxy page download included with the SDK:

1) The proxy.config file is not found when located outside the root folder.  To fix, adjust the following method:

    public static string GetFilename(HttpContext context)
    {
        return context.Server.MapPath("proxy.config");
    }

2) If not token secured, the proxy always checks for Windows\HTTP authentication, which results in a duplication of requests.

Both items have been fixed in the SDK download from this page: http://help.arcgis.com/en/webapi/silverlight/help?Secure_services.htm
0 Kudos