The last meeting between the two countries saw Spain prevail 4-2 on penalties after a 0-0 draw in a quarter-final match at UEFA EURO 2008 in Vienna.
Spain went on to win the trophy, before prevailing in last year's FIFA World Cup in South Africa.
Italy, world champions in 2006, have not beaten Spain since the quarter-finals of the 1994 FIFA World Cup in the United States, registering two defeats and two draws in friendly matches aside from the loss in 2008.
The friendly in Bari will take place before the domestic league championships in the two countries have started.
Spain's La Liga begins on 21 August, with the Serie A season getting under way seven days later.