Web AppBuilder Printing with Secured Map Service

2251
5
09-13-2019 06:51 AM
SandeepKuniel1
New Contributor III

I am trying to configure the print widget available within the Web AppBuilder (which comes with ArcGIS Portal 10.7.1) and it does not work when there is a secured map service inside the webmap.

Background:

1. Have tried to use ArcMap to publish a custom print service with credentials embedded, this seems to work fine for secured service. But, the vector tile from the webmap disappears.

2. Have tried to publish a custom print service from ArcGIS Pro..work fine so long as there is no secured service in the webmap else comes up with an error.

0 Kudos
5 Replies
TanuHoque
Esri Regular Contributor
0 Kudos
SandeepKuniel1
New Contributor III

Hi Tanu,

Thank you for writing back to me, i explored few options as suggested in the above links.

These things did not work for me.

1. ImportCredentials into the GP-- even if this would have worked i do not prefer embedding credentials into the GP.

and i had difficulty in creating an .ags file with saved password inside pro. In order to do this, i had to use ArcMap...which again is a workflow i prefer not to use any more.

2. The python code provided in Web map printing with arcpy.mp—ArcPy | ArcGIS Desktop did not honor dynamic parameters in the layout.

 

Here is what i ended up doing.

1. Made a copy of the Export Web Map python.

2. Wrote a method to generate token from the portal.

3. Manipulated the webmap json which comes as input.

#######################

token = generateToken(username,password,portalUrl)
webMapJson = json.loads(WebMap_as_JSON)
for op in webMapJson["operationalLayers"]:
    op["token"] = token
result = arcpy.mp.ConvertWebMapToArcGISProject(json.dumps(webMapJson), layoutTemplate)

##################

4. Followed the instructions in Share a print service web tool with custom layouts from ArcGIS Pro—Documentation (10.7) | ArcGIS Ent...  

5. And published the modified Export Web Map python as a geoprocessing tool

and it seemed to work for me....

So, until there is an OOB way to do this within the Web App Builder or changes in the Export Web Map tool supplied with the ArcGIS Pro, i do not see a way to print secured service or you may suggest an alternative 

Sandeep

by Anonymous User
Not applicable

Hi @SandeepKuniel1

I'm looking to copy your workaround. 

Are you saying that copied the Export Web Map & Get Layout Templates Info tools into a python script then added this token code to it? 

 

import arcpy
import os
import uuid

token = generateToken(username,password,portalUrl)
webMapJson = json.loads(WebMap_as_JSON)
for op in webMapJson["operationalLayers"]:
    op["token"] = token
result = arcpy.mp.ConvertWebMapToArcGISProject(json.dumps(webMapJson), layoutTemplate)

arcpy.server.ExportWebMap(Web Map as JSON, Output, Format, Layout Templates Folder, Layout Template)

import arcpy
arcpy.server.GetLayoutTemplatesInfo(Layout Templates Folder)
0 Kudos
Pei-SanTsai
New Contributor III

Sandeep, which basemap were you using with your custom print service?  I created print service with credential embedded for my secured map services.  I just recently found out that my print service can't work with some of ESRI default basemap URLs in http://services.arcgisonline.com/ArcGIS/rest/services, but work for URLs with https://basemaps.arcgis.com/arcgis/rest/services

0 Kudos
SandeepKuniel1
New Contributor III

Hi Pei,

We have our own vector tile basemap which is shared across the organization.

So, the basemap was never the issue for the print GP, the problems came with the operational layers added to the webmap

-Sandeep