Skip to content

Instantly share code, notes, and snippets.

@mapbutcher
Created July 30, 2013 03:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mapbutcher/6109889 to your computer and use it in GitHub Desktop.
Save mapbutcher/6109889 to your computer and use it in GitHub Desktop.
/// <summary>
/// Calls the Arc GIS server.
/// </summary>
/// <param name="URI">The URI.</param>
/// <param name="response">The response.</param>
static public void CallArcGISServer(string URI, out JObject response)
{
Stream data = null;
StreamReader reader = null;
try
{
//log the request string
Logger.SystemInfo("Sending request to AGS: " + URI);
WebClientWrapper client = new WebClientWrapper();
var credential = CredentialCache.DefaultNetworkCredentials;
client.Credentials = credential;
data = client.OpenRead(URI);
reader = new StreamReader(data);
string s = reader.ReadToEnd();
response = JObject.Parse(s);
}
catch (Exception ex)
{
Logger.SystemError("An error occured when calling ArcGIS Server" + ex.ToString());
throw;
}
finally
{
if (data != null)
data.Close();
if (reader != null)
reader.Close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment