(CNN) -- Sen. John McCain said Wednesday that Iran's missile test shows the need for an effective missile defense system, while rival Sen. Barack Obama said it shows aggressive diplomacy, combined with sanctions, is necessary.

Sens. John McCain and Barack Obama offered differing views on how best to deal with Iran's latest missile test.

"Ballistic missile testing coupled with Iran's continued refusal to cease its nuclear activities should unite the international community in efforts to counter Iran's dangerous ambitions," McCain, the presumptive Republican presidential candidate, said.

"Iran's missile tests also demonstrate the need for effective missile defense now and in the future, and this includes missile defense in Europe as is planned with the Czech Republic and Poland," McCain said. Watch McCain discuss sanctions against Iran »

Obama, who has faced criticism for saying he would talk with enemies of the United States, released a statement Wednesday calling for direct diplomacy and tougher sanctions.

"Now is the time to work with our friends and allies, and to pursue direct and aggressive diplomacy with the Iranian regime backed by tougher unilateral and multilateral sanctions."

" ... These missile tests demonstrate once again that we need to change our policy to deal aggressively with the threat posed by the Iranian regime. ... Iran now poses the greatest strategic challenge to the United States in the region in a generation."

Obama also said he will continue to push for an incentive package that seeks to deter Iran from its nuclear goals.

"It's time to offer the Iranians a clear choice between increased costs for continuing their troubling behavior, and concrete incentives that would come if they change course," he said.

Don't Miss Iran sends warning with missile test

Iran sends warning with missile test Election Center: Iran

The reaction comes hours after Iran test-fired several missiles in response to what it says are threats from Israel and the United States, according to state-run Iranian media and a U.S. military source.

The state news agency Islamic Republic News Agency and Press TV reported that the naval forces of Iran's Islamic Revolutionary Guard Corps test-fired a Shahab-3 missile during war games in the Persian Gulf.

The exercises come a month after Israel conducted a military drill in the eastern Mediterranean involving dozens of warplanes and aerial tanks.

The latest Iranian activities prompted concern from Israel and condemnation from the United States.

Obama -- while calling Iran a threat -- also criticized the Bush administration for talking tough against Tehran while increasing exports to the country.

Obama's comments referred to a report from The Associated Press Tuesday that America's exports to Iran have increased more than tenfold since President Bush took office.

"It's that kind of mixed signal that has led to the kind of situation that we're in right now," Obama said on ABC Wednesday.

McCain did not criticize the Bush administration's policy toward Iran but said, "The most recent missile tests demonstrate again the dangers it poses to its neighbors and to the wider region, especially Israel."

Policy toward Iran became a primary issue on the campaign trail. Neither of the candidates voted on a September 2007 Senate resolution calling on the administration to declare Iran's Revolutionary Guard Corps a terrorist organization -- a measure that some Democratic critics, including Obama, believed could lead to war.

Although he missed that Senate vote, the Illinois senator heavily criticized his then-chief rival for the presidential nomination, Sen. Hillary Clinton, for voting in favor of the terrorist designation, saying it exhibited the "flawed" judgment she used during the vote to authorize the Iraq war five years ago.

"We know in the past that the president has used some of the flimsiest excuses to try to move his agenda regardless of what Congress says," Obama told CNN in October.

Clinton criticized Obama, as did some Republicans, for saying in a CNN debate last summer that he would be willing to meet with the leaders of Iran, Syria, Venezuela, Cuba, and North Korea "without precondition."

"I would," Obama said at the CNN/YouTube debate last July. "And the reason is this: That the notion that somehow not talking to countries is punishment to them -- which has been the guiding diplomatic principle of this administration -- is ridiculous."

The Obama campaign has since added nuance to that position, particularly regarding meeting with Iranian President Mahmoud Ahmadinejad.

"I would not say that we would meet unconditionally," Obama spokesman and former Sen. Tom Daschle said in May. "Of course, there are conditions that we would involve in preparation in getting ready for the diplomacy.

" 'Without precondition' simply means we wouldn't put obstacles in the way of discussing the differences between us," he said. "That's really what they're saying, what Barack is saying."

McCain and Obama are getting foreign policy and national security advice from star-studded groups of veteran Washington hands.

McCain was one of the first Republican presidential candidates to assemble a team of foreign policy heavyweights.

At a fundraiser in spring 2007, the Arizona senator listed Reagan and Bush I-era officials and conservative thinkers he regularly turned to for input, including Brent Scowcroft, William Kristol, Robert Zoellick, and George Schultz -- with a special emphasis on former Nixon Secretary of State Henry Kissinger.

"When I have a question about something that's going on in the world, I call Dr. Kissinger, and he is able to connect the dots for me," said McCain at the time. Richard Armitage has also been a member of that group.

Robert Kagan, a major proponent of the troop surge in Iraq, has been listed as a leading foreign policy adviser by the campaign. Former CIA Director R. James Woolsey, State Department veteran Richard Williamson and former national security official Peter Rodman are also key advisers.

Obama's foreign policy team has found itself under an uncomfortable spotlight at times, as the International Crisis Group's Robert Malley and Samantha Power, both unpaid advisers, resigned under controversy.

The presumptive Democratic nominee's senior foreign policy team, led by Center for American Progress fellow and former Daschle adviser Denis McDonough, is heavy with names connected with the Clinton era, including former National Security Adviser Anthony Lake, former Navy Secretary Richard Danzig, and Susan Rice -- a former assistant secretary of state.

Since the end of the primary campaign, some of Clinton's top advisers have also reportedly made their way to Obama's circle, including former State Department official Robert Einhorn and Carter foreign policy adviser Stuart Eizenstat.

CNN's Ed Hornick and Rebecca Sinderbrand contributed to this report.

All About Iran • John McCain • Barack Obama