Hello,
I have tried all sorts of things before reaching out here, but I'm afraid I'm stuck. I need to consume a feature layer service from a third party ESRI Portal site. The service is secured using a Dynamic Token and I have been supplied a username and password to access the service. If I simply use a browser to get to the REST endpoint of the service I get prompted to login, which I can and I can see the layers in the service listed, so I know the login works.
My problem is I can't find a complete walk-through of how to do this for the JS API and I've been unable to piece together the information I've found. I'm using V3.28 of the API but I can change that if needed, and I'm using Version 1.1.2 of the Proxy pages, and my app is dot net V4.5. I'm familiar with the Proxy page and its use but not in the context of services with Dynamic Tokens.
So, in my JavaScript I add a proxy rule for where the service is:
esri.addProxyRule({
urlPrefix: "thedomain.co.uk",
proxyUrl: "proxy.ashx"
});
I think the problem then lies in the proxy config. I've found various suggestions online, so what I have below may contain things that aren't required, or are just wrong:
<serverUrl url="https://thedomain.co.uk"
tokenServiceUri="http://thedomain.co.uk/tokens/"
matchAll="true"
domain="thedomain.co.uk"
host="http://mydomain/"
dynamicToken="True"
username="portalUsername"
password="portalpassword"
></serverUrl>
No matter what I've tried, I keep getting prompted with a login box when I launch my API. What I'm trying to achieve is adding the feature service to my map without a login box appearing - I'm expecting the proxy details to handle that as all request to the service will be going through the proxy.
Am I missing something fundamental here? If I had a working example to see then I can usually work things out from it, but I just haven't been able to find one. Can anyone please point me to an end-to-end example or make suggestions here?
Thank you, Mark.
Hi Mark,
Did you test your proxy page with the feature service url? Here are some examples on how to validate your proxy installation and configuration:
1 - Access your proxy page and validate the page without an url: https://<servername>/proxy.ashx?ping
2 - Test the proxy page with the feature service url: https://<servername>/proxy.ashx?<featureserviceurl>
3 - Enable the proxy log file to investigate the error message while trying to acess the feature service Use the ProxyConfig tag to specify property. logFile="proxylog.txt" : When a logFile is specified, the proxy will log messages to this file. N.B.: The folder containing the logFile must be writable by the web server.
Victor,
Thanks for your reply. I know the proxy file works ok because I'm using it for credentials to access one of my own secured map services. When I test using https://<servername>/proxy.ashx?<featureserviceurl> on my own secured service it works fine, but this third-party service from their Portal site gives me this error in a browser:
Line 560: req.Referer = PROXY_REFERER; Line 561: writeRequestPostBody(req, bytes);Line 562: return req.GetResponse();Line 563: } Line 564:
I added the log file to <ProxyConfig as you suggested, but nothing gets written to it for the above error. I deliberately made my secured service error to make sure the log file was working ok and it is.
Something else to mention, I have managed to access the tokens and make requests using dot net NTLM authentication, so I can actually tap into the service and deserialize the JSON to get to features using code behind, but I need to get this to work using JavaScript and the Proxy page. I have been told (when using the dot net NTLM authentication) that I must specify client=requestip like so: request.AddParameter("client", "requestip"). So I was wondering if that has any bearing on the Proxy parameters which I'm currently not doing?
Thanks.