|
{
.
.
.
gov.usgs.gisdata.Greenness_Service svc = new gov.usgs.gisdata.Greenness_Service();
string x_value = "39", y_value = "-77";
string lc = getAllLandCover(svc, x_value, y_value);
MessageBox.Show("Response from getAllLandCover: [" + lc + "]");
// clean up
svc.Dispose();
svc = null;
.
.
.
}
private string getAllLandCover(gov.usgs.gisdata.Greenness_Service svc, string x, string y)
{
string getAllLandCoverResponse = "";
try
{
getAllLandCoverResponse = svc.getAllLandCover(x, y);
}
catch (System.Net.WebException we)
{
// we're being redirected by the web service so set the
// proxy to point to the new URL.
System.Net.HttpWebResponse wr = (System.Net.HttpWebResponse)we.Response;
System.Uri u = new Uri(svc.Url);
svc.Url = u.Scheme + "://" + u.Host + wr.Headers["Location"];
// invoke this method again with the new URL
getAllLandCoverResponse = getAllLandCover(svc, x, y);
}
catch (Exception ex)
{
getAllLandCoverResponse = ex.Message;
}
return getAllLandCoverResponse;
}
|