Print Dijit Woes

1256
5
Jump to solution
09-25-2013 08:34 AM
MatthewLawton
Occasional Contributor
I've searched the forums for a problem similar to mine, but haven't been able to find an applicable thread. I have a fairly complex JavaScript API application I have been developing since version 1.4. I am currently on JSAPI version 3.4 and am running my services on ArcGIS Server 10.1. I am finally getting around to setting up the Print dijit in my app, but keep running into errors. Since the latest 3.6 documentation uses the AMD referencing method, I have found it difficult to find examples that make sense in my application, but here is what I have basically added to my code to get a print button on my app:

  esri.config.defaults.io.proxyUrl = "http://" + hostName + "/proxy/proxy.ashx";   var printer = new esri.dijit.Print({     map: map,     url: "http://" + hostName + "/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task"   }, dojo.dom.byId("printButton"));   printer.startup();


I also added the necessary Require statements for the Print dijit and the Dojo DOM. I set up the proxy code per the ASP.NET download and instructions. I have added a "printButton" DIV to my HTML. The application loads fine, no errors, and the print button is visible. However, when I click on the print button I get a few seconds of wait time and then the following error in Chrome:

Error {code: 400, message: "Unable to complete operation.", details: Array[1], log: undefined}  init.js:15 _49d init.js:15 (anonymous function) init.js:15 _1e1 init.js:15 _1df init.js:15 resolve.callback init.js:15 _1e1 init.js:15 _1df init.js:15 resolve.callback init.js:15 _1e1 init.js:15 _1df init.js:15 resolve.callback init.js:15 _1e1 init.js:15 _1df init.js:15 resolve.callback init.js:15 (anonymous function) init.js:15 _4c2 init.js:15 _4bc init.js:15 resolve init.js:15 _4c8 init.js:15 _4c2 init.js:15 _4bc init.js:15 resolve init.js:15 _4c8 init.js:15 _4c2 init.js:15 _4bc init.js:15 resolve init.js:15 _4c8 init.js:15 _4c2 init.js:15 _4bc init.js:15 resolve init.js:15 _3e6 init.js:15 _3f2


My "Export Web Map Task" is running on my local ArcGIS Server 10.1 deployment. I also tried referencing the ESRI hosted task, but I get the same error. The button seems like it is trying to do something, but I just don't get the response, instead just the error. I'm pretty lost here. Am I missing a parameter? Am I not initializing the tool properly in my code? Is my proxy not configured correctly (how would I test that)? Is it an issue with the Export service?

Any help and direction would be greatly appreciated.
0 Kudos
1 Solution

Accepted Solutions
JohnGravois
Frequent Contributor
do you see an actual request to your print service in the web traffic or does the error appear in the console before it even fires? 
if you're issuing a request, does it use the proxy?
have you considered setting up our simple print dijit sample and pointing it at your own service to make sure things are working on the server?

View solution in original post

0 Kudos
5 Replies
JohnGravois
Frequent Contributor
do you see an actual request to your print service in the web traffic or does the error appear in the console before it even fires? 
if you're issuing a request, does it use the proxy?
have you considered setting up our simple print dijit sample and pointing it at your own service to make sure things are working on the server?
0 Kudos
MatthewLawton
Occasional Contributor
John, hosting the Esri sample is a brilliant idea. I grabbed the code and put in on my server. It worked just fine, just like the Esri hosted sample. I modified the print URL to point to my export service and I got a different error (a timeout). So it does appear that there is some issue with my local print service. Anyway, I went back to my app code and changed it to the Esri hosted export service, like in the sample code, but I still get the "Error code:400". I pointed the Esri sample code to my proxy, and the sample still works, so I assume my proxy is not the problem?

I checked the network traffic and my app does show an execute request (GET) to the Esri export service with a wait time of 643ms and a response of 200ms. The working sample code shows a similar request with a wait time of 2.49s and a response time of 200ms. So it looks like there is communication, but maybe there is a parameter in my map that the export service doesn't like? I can't find anything that appears out of sorts.

I changed the sample code to point to JSAPI 3.4, like my app, and the sample still works. I've gradually been fiddling with each code set to get them to look as similar as possible, but the result is still that the sample works just fine and my app keeps throwing the error. This probably means I am missing some little inconsistency in my app code. The main difference I can see in my app is that it is still using the "legacy" module requires and the sample is using the AMD module requires. I guess maybe I need to take the leap and just update all of my code to use the AMD style.

Any additional guidance is much appreciated.
0 Kudos
JohnGravois
Frequent Contributor
no guarantee, but i'd bet $5 that your print service is set up as asynchronous (ie: has a 'submitJob' operation and not an 'execute' operation.)

if so, either change the service property in server manager or set 'async' to true in the widget constructor.

var printer = new esri.dijit.Print({
    async: true,
    map: map,
    url: "http://" + hostName + "/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task"
  }, dojo.dom.byId("printButton"));
0 Kudos
MatthewLawton
Occasional Contributor
I am such a freakin' bonehead!

I am hosting the app on my internal dev server and pointing to my internal dev map services, not accessible to the outside. So of course the Esri Export service can't see my map! Duh!

I switched my code to point to my live map services and everything works fine.

John, thanks for your help!
0 Kudos
JohnGravois
Frequent Contributor
glad to hear you're sorted out.
0 Kudos