Refactor soap call into a function.