2

ArcGIS Server Version: 10.4.0 ArcGIS JS API: 3.25 ArcGIS Desktop: 10.2.1 Browser: IE 11

In my web application, I am consuming secured services and have a requirement to print the map contents.

Initially, the token expiry was set to default (i.e. 60 mins) and everything worked fine including printing, using the Utilities/PrintingTools GP Service.

As part of the requirement, the token expiry was increased from 60 mins to 240 mins - everything still worked fine except for printing! Looking up the esri help it was clear I had to create a custom service. I created the custom service as described in the help documents, but it still fails with the following error:

Error executing tool. Export Web Map Task Job ID: jb88972125ace4b6593c8055ee779e920 : Layer "dynLyrId": Unable to connect to map server at https://server.domain:6443/arcgis/rest/services/WebViewer/MapServer/. Failed to execute (Export Web Map). Failed to execute (Export Web Map Task).

The custom service has a user connection (with saved credentials) embedded into it as required.

Upon investigating further, I found out that if I remove the token from the WebMapAsJson, it works like a charm (in ArcCatalog at least)!

I don't know how to do that as I am not creating the WebMapAsJson manually, but the esri JS API creates it while sending the request. I also tried to increase the ArcGIS Servers' shortTimeout value from 60 to 240 but even that failed.

Any ideas to make the printing work with long-validity tokens?

2
  • This may help. Looks like if the token is generated using HTTP Referrer then it fails, but using requesting IP in the export map object it works. community.esri.com/thread/71088
    – enolan
    Oct 9, 2018 at 17:18
  • I generate the token after the user successfully logins to the application. The token is generated using the 'RequestIP' parameter - so I don't think the HTTP referrer scenario would apply. If I remove the token then the print request goes without any issues.
    – ujjwalesri
    Oct 11, 2018 at 5:14

1 Answer 1

0

Okay, so after trying all possible solutions and none of them working - I had it working as follows:

  • The PrintTask object was created as usual, along with other parameters
  • Fetched the map as JSON using the much useful but undocumented function: printTaskObj._getPrintDefinition(map, params)
  • Removed the token from the WebMapJSON
  • Added ExportOptions to the JSON above
  • Prepared the parameters manually, and called the execute REST endpoint (using standard XHR) for the GPTask. This is important as now I don't need to trigger the .execute() method of the task.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.