Check if a service is protected in a workflow(standard)
Hi,
Is there a way to know if an AGS service is protected before calling a query task in a workflow?
Because I need to determine whether to pass it a token or not since if a service is not protected and receives a token it throws an error saying "invalid token".
Right now I'm using a try catch activity and if it throws an error I use a query task with an empty token on the catch phase but this is a "ugly" solution.
Thanks in advance
0
-
You could try cobbling something together using the Web Request activity, but I would recommend that you simply check the endpoint while writing the workflow to determine whether to use a token. I don't know why you'd need to determine this dynamically, surely your services don't shange their security particularly often. 0 -
Thanks for the answer.
Well, in short, we don't manage the services, the clients do, so I was trying to find a way of preventing( when they unsecure/secure a service) the workflow from crashing.
Can you clarify what you mean by "checking the endpoint"? Through the Web request? Can you give an example?
Thanks again.0 -
What I found to be the best way is to always use the Get Map Service Info activity, and use its Token output, even if the mapservice is not protected. The variable will be empty for non-protected mapservice and will be ignored by e.g. the Query Task activity.
You can't use this approach if the mapservice you are using is not added to the site. In that case you will have to use a WebRequest activity with a GET request to the mapservices endpoint, e.g. https://server/arcgis/rest/service/MyService/MapServer?f=json. The response will be something like this:{"error":{"code":499,"message":"Token Required","details":[]}}0 -
Thanks for the answer.
That's the case. sometimes the service is not added to the map hence why I didn't go with the Get Map service approach.
For the Webrequest it's essentially the same as the Try Catch business wise. It has to throw an error before I know if it's protected or not.
Thanks0 -
In you look at it that way, everything is essentially the same as the TryCatch thing. The only way to know the status of any web service (that's not used in the site.xml) is to do an extra request to that service.
The only difference in my example is that no exception is thrown, so you don't need a try catch. This makes the workflow a bit easier to read.0
Please sign in to leave a comment.
Comments
5 comments