PrintTask not exporting the map, ArcGIS Server 10.2, ArcGIS Javascript API 3.6

4843
1
09-25-2013 08:00 AM
KaushalShah
New Contributor
I have created the print task code but its not exporting the map. I need to export map and then download for the user.
I have added basemap, my custom rest services, some esri live feed rest services, some graphics on the map.
I have tried my local server geoprocessing printtask, and the esri online printtask, but none of them returns the exported map url..

I have also used the proxy page for this and have tried without enabling the proxy but none way works.

I am pasting the javascript method for reference which is being called upon button click after the map loads.
I have tried with the commented codes also.

function exportMap() {
    //    var map1 = new esri.Map("map",
    //                { slider: true, basemap: "streets", logo: false });

//    var url = 'http://servicesbeta4.esri.com/arcgis/rest/services/Utilities/ExportWebMap/GPServer/Export Web Map Task';
//    var url = 'http://ms02291/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export Web Map Task';
//    var printTask = new esri.tasks.PrintTask(url);

//    var printResult = function (result) {
//        console.log(result)
//        alert(result);
//    }

    var template = new esri.tasks.PrintTemplate();
    template.exportOptions = {
        width: 500,
        height: 400,
        dpi: 96
    };
    //template.format = "PDF";
    template.format = "JPG";
    template.layout = "MAP_ONLY";
    template.showAttribution = false;
    //template.preserveScale = false;

    var params = new esri.tasks.PrintParameters();
    params.map = map;
    params.template = template;


    //    printTask.on("complete", printComplete);

    //    printTask.execute(params, printResult);

    //print task
    //var printTask = new esri.tasks.PrintTask("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export Web Map Task");
    //var printTask = new esri.tasks.PrintTask("http://ms02291/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export Web Map Task");
    var printTask = new esri.tasks.PrintTask("http://ms02291/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task");
    printTask.execute(params, function (result) {
        alert(result.url);
        window.open(result.url);
    });
}


This is very urgent. Please help to rectify the issue.
Regards,
Kaushal Shah.
0 Kudos
1 Reply
KaushalShah
New Contributor
My issue was that the internet was not working on arcgis server machine. The code was fine.

Fiddler installation helped in finding the issue by reading request and response parameter values.

From Fiddler I found the map exportoptions json string generated by running my code in IE, and then ran it on print web map task service of my server.
http://ms02291/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task/execu...

The fiddler showed the error that about the online esri basemap. The error was that:
Unable to complete operation.
Error executing tool.: Layer "layer0": Unable to connect to map server at http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer. Failed to execute (Export Web Map). Failed to execute (Export Web Map Task).

The below forum link had helped to resolve above error.
http://forums.arcgis.com/threads/56702-Export-Web-Map-Task-Error-quot-Unable-to-connect-to-map-serve...

The below was the solution link in the above link. The internet had to be configured and run with the "arcgis" user of arcgis server on the server machine to connect to online (internet) url services.
http://resources.arcgis.com/en/help/main/10.1/index.html#//015400000309000000

Finally I was able to export my map with basemap.

The graphics is still not exporting but that is a separate case.

All the best. For any troubleshoot further I can be reached below.

Regards,
Kaushal Shah, India.
+91 9891626907, kaushal.shah@tcs.com
0 Kudos