ConvertWebMapToMapDocument Python Script With Secure Map Services

2976
6
03-21-2013 11:37 PM
ShaunWeston
Occasional Contributor
I've developed a python script for use in a web application, which works fine for public services, but does not work with secure services. I've setup some code in the script to hopefully handle secure services:

serverConnection is a variable, which holds the path to a user connection to the arcgis server
server = {}
server['SERVER_CONNECTION_FILE'] = serverConnection
result = arcpy.mapping.ConvertWebMapToMapDocument(webmapJSON, templateMxd, extra_conversion_options=server)


So I can publish it to server and print public map services, but secure services come back with this:

Unable to connect to map server at  ..."},{"type":"esriJobMessageTypeInformative","description":"Layer \"Licences\": Unable to connect to map server at http://gis.mstn.govt.nz/arcgis/rest/services/RegulatoryAndInspection/Licences/MapServer?token=I-eon3...


o I've setup the tokens to pass in a flex app and the tokens are HTTP Referrer (in fact I've tried lots of different token options but nothing works!). Why does it have this error?
Tags (2)
0 Kudos
6 Replies
nicogis
MVP Frequent Contributor
is serverConnection file accessible to local user arcgis of ags?
0 Kudos
JeffMoulds
Esri Contributor
Check out the sample in the extra_conversion_options parameter help in the ConvertWebMapToMapDocument help topic. You'll want something like this:
dict = {"SERVER_CONNECTION_FILE":r"Z:\share\ArcGIS2 on MyServer (user).ags"}
result = arcpy.mapping.ConvertWebMapToMapDocument(json, extra_conversion_options=dict)


Some things to check:
- Open the connection file in the catalog window in ArcMap and make sure you can see the secure service without being prompted for credentials.
- Make sure the connection file has "save username and password" checked on.
- If you are testing this as a GP service, make sure the server can see the path to the connection file.
0 Kudos
ShaunWeston
Occasional Contributor
I've tried all those suggestions and nothing works it just always shows the Unable to connect to map server error when I look in fiddler. I don't understand what the issue is the arcgis account can definitely see it and I'm using the administrator login/password, which is saved and can see the secured service when I look through ArcCatalog.
0 Kudos
ShaunWeston
Occasional Contributor
Ok it's something to do with the token as it works fine if I enter the credentials into IdentityManager (this is for a flex application), but just doesn't work with a token attached to the map service.
0 Kudos
TanuHoque
Esri Regular Contributor
0 Kudos
MayJeff
Occasional Contributor
Do you able to add secured services to your python script? Thanks.
0 Kudos