LanceWeaver

problems with using the proxy.php for edits

Discussion created by LanceWeaver on Apr 11, 2012
I thought I would post this to the forums since it took me hours to solve.

I could not get the proxy.php page to work on my setup (WAMP server).  The request fired from the Attribute Inspector or Editor would simply time out.  Firebug gave an error of "XML Parsing Error: no element found Location: moz-nullprincipal:{78a64f8b-a468-4122-8af0-356a8e931a72} Line Number 1, Column 1:"  Which is just a default Mozilla error meaning the request timed out.   I read a number of old esri forums post that said things like your application had to be on the same machine as your ArcGIS server  (not true, you dont need a proxy in that situation.  Your application and your proxy.php have to be on the same server, but they can/will be on a different server than your ArcGIS Server).

The solution for me ended up being a firewall issue where proxy requests had to be made to the ArcGIS server's externally facing IP address.   Its host name would not work. nor would its internally facing IP.  So I created a function to place in the proxy.php which solved the problem.


  // this function replaces the domain in serverURL's with the IP if it is defined.  this way we dont have to expose our IP in our webpages featureLayer definition
  $replacementIP = $serverUrls[$pos]['ip'];
  if ($replacementIP) {
     $host = parse_url($targetUrl, PHP_URL_HOST);    //parse out the host or domain from url
     $targetUrl = str_replace($host,$replacementIP,$targetUrl); //replace host with ip in url string
  }


I placed this function directly below the following function

  // add token (if any) to the url
  $token = $serverUrls[$pos]['token'];
  if ($token) {
    $targetUrl .= (stripos($targetUrl, "?") !== false ? '&' : '?').'token='.$token;
  }


You then must add a 'ip' variable in the $serverUrls Array.   for example
array( 'url' => 'http://myArcServerDomain.com/ArcGIS/rest/services/', 'ip' => '192.168.1.3', 'matchAll' => true, 'token' => '' )

Works like a charm
hope that helps someone

Outcomes