Код: Выделить всё
private String SendGetRequest(String urlParam) throws IOException
{
String ResStr = "";
// Create an instance of HttpClient.
HttpClient client = new HttpClient();
// Create a method instance.
GetMethod method = new GetMethod(urlParam);
// Provide custom retry handler is necessary
method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false));
try
{
// Execute the method.
int statusCode = client.executeMethod(method);
if (statusCode != HttpStatus.SC_OK)
{
System.err.println("Method failed: " + method.getStatusLine());
}
// Read the response body.
ResStr = method.getResponseBodyAsString();
}
catch (HttpException e)
{
System.err.println("Fatal protocol violation: " + e.getMessage());
throw e;
}
catch (IOException e)
{
System.err.println("Fatal transport error: " + e.getMessage());
throw e;
}
finally
{
method.releaseConnection();
}
return ResStr;
}
http://192.168.*.*/nom/reverse?format=json&lat=47.2&lon=39.6&zoom=17&addressdetails=1
Подскажите, пожалуйста или еще лучше выложите код, с такой же функцией на C#.
Как написать запрос к базе данных Nominatim через C#.
И можно ли в принципе в этом запросе получить ответ не в формате JSON а в формате XML?