It is considered bad practice because you are mixing responsibilities. Your Database connection stays open while calling the HTTP service.
To make it more concrete: imagine a stall in the HTTP server and a high load on this particular function. In that case you'll have several DB connections open at the same time. This can cause unwanted side affects. For example Record locking (especially when you are also using write actions) or you could even hit your maximum DB-connection count.
A better approach would be to fetch the data first and than call your HTTP service. The code might look more like this:
List<Items> items = null;
using(var dbContext = contextFactory.GetContext())
{
items = dbContext.Items.ToList(); //query all the items
}
//now loop the items
foreach(item in items )
{
try
{
var result = IRemoteWebService.SomeOperation(item);
}
catch(MyException e)
{
//assume that all possible exceptions are caught
}
}
It would be even better if you create sepperate methods, (put them in different classes even), for your data-query and http-call. This way you can reuse the code better and it's easier to maintain, more flexible en better testable.
As for a general note: it's best to keep things like connections (db, http, tcp/ip, filesystem etc.), graphics, locks, etc. open for the shortest time possible. There are of course performance optimization arguments which can argue this statement, but these are seldom valid since code complexity will increase at its cost.