Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have OpenLayers ProxyHost configured

OpenLayers.ProxyHost= "form/proxy?url=";

, the url config of Mapfish Print Provider is configured as http://path/to/mapfish/print, and the doc tells that I can do that as it is accessible throug the proxy

This property requires that the print service is at the same origin as the application (or accessible via proxy).

, but the lib still tries to go to other origin directly and fails.

I cannot find where to configure GeoExt or ExtJS to go there through proxy.

The Mapfish Print doc tells to set some parameter of a mapfish variable, I did that but obviously with no success.

Please, help!

(Actually, it's GeoExt 2 for ExtJS 4, where the PrintProvider seems being renamed as GeoExt.data.MapfishPrintProvider)

share|improve this question

2 Answers 2

Because Geoext2 they remove override-ext-ajax.js, but you can mortify urls like this

printCapabilities.createURL="./ProxyHost.ashx?url="+printCapabilities.createURL;

printCapabilities.printURL="./FTProxyHost.ashx?url="+printCapabilities.printURL; 

printCapabilities is from http://localhost:8080/geoserver/pdf/info.json?var=printCapabilities.

It works fine for me.

share|improve this answer

Adding the OpenLayers.ProxyHost will only proxy requests that OpenLayers itself makes and won't proxy requests from the GeoExt framework. But actually you do not need to use a proxy as you can put the request for the Print Capabilities into your page's header as a script tag like this:

<script src="http://path/to/mapfish/print/info.json?var=printCapabilities type="text/javascript"></script>

Then all you need to do in your print provider is reference the printCapabilities variable like this:

// The printProvider that connects us to the print service
var printProvider = new GeoExt.data.PrintProvider({
    method: "GET", // "POST" recommended for production use
    capabilities: printCapabilities, // from the info.json script in the html
    customParams: {
        mapTitle: "Printing Demo",
        comment: "This is a simple map printed from GeoExt."
    }
});

Then all requests for printing should work as the url is stored in the printCapabilities object. This is the approach I use for printing from my web appications.

share|improve this answer
    
thanks! unfortunately the problem remains as after that it still needs to go to http://xxxxx/print/pdf/create.json with XHR, and it's against the same origin policy again. this url is configured in printCapabilities and is not available for me to edit. –  fedd Jul 27 '12 at 10:05
1  
I think in the PrintProvider you can swap the "capabilities" property for a "url" property instead. In which case you could do "form/proxy?url=path/to/mapfish/print"; - then I think the PrintProvider will use this url which should route it through your proxy for all requests. –  CHenderson Jul 27 '12 at 23:29
    
must be good idea! unfortunately i couldn't make it work as createURL and printURL of print capabilites were specified as absolute URLs, with the domain - I faced the same error. maybe it's an error of mapfish printing servlet deployment, need to talk to it's admins which takes time... –  fedd Jul 30 '12 at 9:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.