Several train wagons have derailed in South Australia, affecting key freight services connecting the country.