Secured Printing Service

8664
17
Jump to solution
03-25-2015 08:04 PM
SaurabhGupta5
Occasional Contributor

Hello All,

I am using ArcGIS Server 10.2.2 default printing service gp service but it is not working for secured services. All the services are secured using ArcGIS Builtin security model and i am also using proxy page in between to talk to these services but when i am using printing gp service it is not working. what could be the issue. please help.

Thanks

0 Kudos
1 Solution

Accepted Solutions
SaurabhGupta5
Occasional Contributor

Here i found the solution of this issue

look at the following page:

https://github.com/djarrard/WebmapWrappers#webmap-wrapper-project

It is provided as a workaround for such scenario. The
link provides a python file to download along with its project package.

What it does is modifying the webmap JSON prior to
executing a print task. It is what's needed in the your scenario (Insert token
with printing secured services when the application uses a proxy page).

However, just like Jim mentioned in post,
the username and password to ArcGIS Server are configured explicitly, but this
time configured within the python script.

Hope this will be helpfull for lot of developers working on version 10.2.2

Saurabh

View solution in original post

17 Replies
JimFaulkner
New Contributor III

In ArcCatalog, copy the "Export Web Map" tool and paste in a new toolbox with a name like "Secure Printing". Right-click on the copied tool and select "Edit". Click the "Add" (the plus sign) and choose an ArcGIS Server connection that has the rights / privileges to the secure service you're wanting to print from. Click "OK". Now, run the tool and leave the "Web Map as JSON" blank, select your template and layout (if you want). When the tool is completed, in the "Geoprocessing Results" window, right-click the "Export Web Map" result and choose "Share As" --> Geoprocessing Service. When you're finished uploading that service, it can now be used to print from the secured web map / service.

0 Kudos
SaurabhGupta5
Occasional Contributor

Hi Jim,

Thanks for your quick reposne!!

I am publishing my print service using same method you have provided and as given in below url but no sucess

ArcGIS Help (10.2, 10.2.1, and 10.2.2)

I tried looking into my JSON string and i find that it is not prepending the proxy url against map services, is that the issue? Because when i manually put proxy url as a prefix , gp seems to returning blank pdf?

{"exportOptions":{"dpi":96},"mapOptions":{"extent":{"xmax":19154.03163255061,"ymin":43083.54582798357,"xmin":15539.81607078615,"ymax":43964.610090112095,"spatialReference":{"wkid":3414}}},"layoutOptions":{"titleText":"er","copyrightText":"Copyright ©2015 Public Utilities Board (PUB). All rights reserved.","authorText":"GERI","legendOptions":{"operationalLayers":[{"id":"BWAS"},{"id":"BQ Polygon"},{"id":"BQ Segment"},{"id":"HDB Dwellings & Water Efficiency"}]}},"operationalLayers":[{"id":"Street View","maxScale":250,"title":"Street View","url":"http://gisdevqa1/egisqa/rest/services/GERI_Geospace/streetdirectorycache/MapServer","minScale":250000},{"id":"Water Property Critical","visibleLayers":[0],"maxScale":0,"title":"Water Property Critical","url":"http://gisdevqa1/egisqa/rest/services/GERI_WSN/wsnwaterpropertycritical/MapServer","minScale":0}]}

Please help!!

Regards

Saurabh

0 Kudos
JimFaulkner
New Contributor III

It appears to be a problem with both the proxy url and the fact that I do not see the token being passed to the gp service. Whenever you use a secured service, you have to pass the token to the GP service.

0 Kudos
JimFaulkner
New Contributor III

Here is what I post to my secure printing service through a proxy url:

FormatPDF
Web_Map_as_JSON{"layoutOptions":{"customTextElements":[{"mapTitle":"Map Test"}]},"operationalLayers":[{"url":"http://10.1.2.87:6080/arcgis/rest/services/water-resources/utility_basemap_manual_layers/MapServer","visibility":true,"visibleLayers":[0,12,21,24,25,26,27,28,29,30,31,32,33,34,35,36]},null],"exportOptions":{"dpi":96},"mapOptions":{"extent":{"xmin":393829.38643702905,"ymin":1559480.6243272335,"xmax":621170.6135629709,"ymax":1730519.3756727665},"scale":"227341.23"}}
fpjson
tokendXTfSB7wlOUezjLVyAoEHm6kkGP0CUgrng77jdKM34ATLGQHyOMx-VpK3w4HxBo0wChP9zAuCdIhLsqvqg5bjA..
urlhttp://10.1.2.87:6080/arcgis/rest/services/secure-print-services/SecureBOCCLandscapeTemplate/GPServe.../Export Web Map/execute
0 Kudos
SaurabhGupta5
Occasional Contributor

Hi Jim,

Thanks for your quick reply!!

I am using standard proxy provided by ESRI and it is creating token internally while accessing any map services. I do not know why it is not appending token while calling gp , may be handling internally not sure.

Can you please tell how are you doing in your case , i mean have you written code to append token while calling gp. if yes can you please provide me set of lines.

Many Thanks!!

0 Kudos
JimFaulkner
New Contributor III

I wrote my own code using javascript, but, all I am doing is "POST"ing through my own proxy (very similar to the ESRI proxy). My proxy is: http://my.domain.com/media/feed.jsp  and if you look at my previous reply, you'll see what I am posting. the "url" parameter is the GP service for printing my secure map services. I have created my own JavaScript library for getting / storing the token (using cookies). So, my post literally looks like this:

http://my.domain.com/media/feed.jsp?url=http://10.1.2.87:6080/arcgis/rest/services/secure-print-services/SecureBOCCLandscapeTemplate/GPServe...

0 Kudos
SaurabhGupta5
Occasional Contributor

Hi Jim ,

As per your comment i have modified my url like this and trying it manually means copying and pasting to my browser , just to see whether it returns anything or not. is this correct way to check ? I mean manually passing this complete url to IE amd press enter should return sth?

Token also i have generated myself using http://servername/egisqa/tokens/generateToken and passing 'http://gisdevqa1/egisqa/rest/services ' in http referrer

http://gisdevqa1/Proxy/proxy.ashx?url=http://gisdevqa1/egisqa/rest/services/ExportWebMap/GPServer&Fo...{"layoutOptions":{"authorText":"GERI","titleText":"sg","legendOptions":{"operationalLayers":[{"id":"Others"},{"id":"Clouds Over Time"},{"id":"GEOSPACE"},{"id":"Geometric Network (Network Trace)"},{"id":"CWD Notification System"},{"id":"Drainage Map (DIMS)"},{"id":"Water Quality & Contract Boundary"},{"id":"Planning Boundary"},{"id":"WRN Notification Map"},{"id":"Sewerage Map (SIMS)"},{"id":"Potable Water Supply Zones"},{"id":"Demand Zones"},{" id":"BQ Segment"},{"id":"HDB Dwellings & Water Efficiency"}]},"copyrightText":"Copyright ©2015 Public Utilities Board (PUB). All rights reserved."},"exportOptions":{"dpi":96},"mapOptions":{"extent":{"spatialReference":{"wkid":3414},"xmax":71930.5746856367,"ymin":23128.63091815375,"xmin":-18424.81435847472,"ymax":45750.55116199424}},"operationalLayers":[{"id":"Street View","maxScale":250,"title":"Street View","url":"http://gisdevqa1/egisqa/rest/services/GERI_Geospace/streetdirectorycache/MapServer","minScale":250000},{"id":"Water Property Critical","visibleLayers":[0],"maxScale":0,"title":"Water Property Critical","url":"http://gisdevqa1/egisqa/rest/services/GERI_WSN/wsnwaterpropertycritical/MapServer","minScale":0}]}

Infact i am getting following error

{error: {code: Forbidden,message:"Proxy is being used for an unsupported

service:

url=http://gisdevqa1/egisqa/rest/services/ExportWebMap/GPServer&Format=PDF&f=pjson&token=OdvOcdKGQp-4EY6..."}}

0 Kudos
JimFaulkner
New Contributor III

The error you're getting is because you need to test it doing an http "post", not a "get". If you make a test web page with a form and a submit button, you should be able to get it to work:

<form action="http://youproxyurl/" method="post">

  <input type="hidden" name="Format" value="PDF" />

  <input type="hidden" name="token" value="token value here" />

  <input type="hidden" name="f" value="pjson" />

  <input type="hidden name="Web_Map_as_JSON" value="{'layoutOptions':{'authorText':'GERI','titleText':'sg','legendOptions':{'operationalLayers':[{'id':'Others'},{'id':'Clouds Over Time'},{'id':'GEOSPACE'},{'id':'Geometric Network (Network Trace)'},{'id':'CWD Notification System'},{'id':'Drainage Map (DIMS)'},{'id':'Water Quality & Contract Boundary'},{'id':'Planning Boundary'},{'id':'WRN Notification Map'},{'id':'Sewerage Map (SIMS)'},{'id':'Potable Water Supply Zones'},{'id':'Demand Zones'},{' id':'BQ Segment'},{'id':'HDB Dwellings & Water Efficiency'}]},'copyrightText':'Copyright ©2015 Public Utilities Board (PUB). All rights reserved.'},'exportOptions':{'dpi':96},'mapOptions':{'extent':{'spatialReference':{'wkid':3414},'xmax':71930.5746856367,'ymin':23128.63091815375,'xmin':-18424.81435847472,'ymax':45750.55116199424}},'operationalLayers':[{'id':'Street View','maxScale':250,'title':'Street View','url':'http://gisdevqa1/egisqa/rest/services/GERI_Geospace/streetdirectorycache/MapServer','minScale':25000...},{'id':'Water Property Critical','visibleLayers':[0],'maxScale':0,'title':'Water Property Critical','url':'http://gisdevqa1/egisqa/rest/services/GERI_WSN/wsnwaterpropertycritical/MapServer','minScale':0}]}" />

<input type="submit" value="Submit" />

</form>

** Note: Make sure you replace the double quotes in the JSON with a single quote like I did above **

SaurabhGupta5
Occasional Contributor

Hi Jim,

You were very helpfull but now getting different error by your way.i.e.

{

"error": {

  "code": 498,

  "message": "Invalid Token",

  "details": []

}

}

i tried generating token diffreent ways like http referrer , ip but no token seems to be working. I was using following url to generate token i.e. http://servername/egisqa/tokens/generateToken

Any suggestions on same

Thanks

0 Kudos