PrintTask, Secure AGS Service, and Resource Proxy

9012
10
02-25-2016 08:48 AM
deleted-user-RAnWn8DDSd1P
New Contributor III

I use the .NET proxy to run transparent token auth for a secure service. URLs to the secure service in the Web_Map_as_JSON cause the PrintTask execute to fail 400, citing the secure service URLs.  I've tried proxying the execute call to fetch a token and changing the URLs in the Web_Map_as_JSON to go through the proxy but no dice.  I've seen this article referenced in response about this problem, but we have short lived tokens and the way this article reads we shouldn't need a custom print service. Is it possible to use PrintTask with a webmap definition referencing secure services by somehow using the resource proxy or do we need to go this route with the custom print service? 

10 Replies
ChristopherSchreiber
Occasional Contributor II

Hello,

I have discussed a modification to the Esri Resource proxy that will allow for secured services to be printed. 

Please see this discussion: Web AppBuilder Print widget and proxy service 

Here is what I was able to come up with:

NOTE: These would only work for the DotNet version of the Esri resource proxy.

 

  1. Get the "Web_Map_as_JSON" (WMAJ) parameter (and data it contains) from the the request. 
  2. Using a library like Newtonsoft.Json, deserialize the WMAJ data from a JSON object into a DotNet Object
  3. Get the "Operational Layers" section of the WMAJ object and add each layer into an array.
  4. Compare the Layer URL's of the layers from the WMAJ object and the URL's that are defined in the proxy.config file.
  5. If a layer's URL matches a URL from the proxy config file, use the credential info to generate a token for it.
  6. Apply the token to the layer in the array of "Operational Layers"
  7. Serialize the DotNet WMAJ object (now with tokens for the secured layers) and send the request on its way.

I hope this helps, 

Chris

0 Kudos