[OpenLayers-Users] Using Cross Domain JSON to get around a proxy issue

Robert Sanson Robert.Sanson at asurequality.com
Mon Sep 19 23:48:31 EDT 2011


I am wanting to access a WFS data service outside our company's network, and I have been having trouble trying to get my proxy to work through our firewall. One possible solution is to use Cross Domain JSON to get around this. The WFS server I want to access can return JSON wrapped in a callback function if requested, by appending: &outputFormat=json&format_options=callback:myCallback to the URL.
 
(refer to these articles: http://snook.ca/archives/javascript/cross_domain_aj 
 and
http://www.xml.com/pub/a/2005/12/21/json-dynamic-script-tag.html 
for a description of the technique).
 
Has anyone managed to get this to work with OpenLayers?
 
Here is my WFS code:
 
    var parwfs = new OpenLayers.Layer.Vector("WFS Parcels", {
      strategies: [new OpenLayers.Strategy.BBOX()],
      protocol: new OpenLayers.Protocol.HTTP({
      url: "http://wfs.data.linz.govt.nz/MYKEY/wfs",
      headers: {"Content-Type": "plain/text"},
      params: {
         version: "1.0.0",
         service: "WFS",
         request: "GetFeature",
         //srsName: "EPSG:2193",
         maxfeatures: "5",
         typename: "x823",
         outputFormat: "json",
         format_options: "callback:getGeo"
      },
      format: json_format
      }),
      projection: new OpenLayers.Projection("EPSG:4326"), 
      style: {strokeColor: "green", strokeWidth: 2, strokeOpacity: 0.5},
      minScale: 50000,
      visibility: false
    });
    map.addLayer(parwfs); 
 
How would I handle the sending to avoid it using XMLHttpRequest? And what about passing the response to a the callback function?
 
Thanks,
 
Robert Sanson
 


This email and any attachments are confidential and intended solely for the addressee(s). If you are not the intended recipient, please notify us immediately and then delete this email from your system.

This message has been scanned for Malware and Viruses by Websense Hosted Security.
www.websense.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110920/eafb01c1/attachment-0001.html


More information about the Users mailing list