"Significant reliable evidence was presented at the hearing that discredited the purported identification and went further by establishing that it could not be him," he said.
The witness, whose name was also suppressed, said she first thought it was a man urinating in public but as she got closer it was clear he was enjoying the moment.
The complainant said on the August occasion the man appeared more confident and he stood closer to her, prompting another call to police.
Because of the woman's description and the fact the defendant had previously been granted diversion for doing an indecent act - masturbating in his car in Mt Eden - he became the main suspect in the case.
Five days after interviewing the complainant Constable Dimitry Pantileev showed her a photo board on which she picked out the defendant but Mr Mansfield questioned the way the identification procedure had been executed.
The woman had previously been shown a photo board over the earlier incident from which she could not pick out the man.
The only common picture between the two boards was that of the defendant, which was in the same position as it had been at her first viewing.
Mr Mansfield suggested that jeopardised the validity of the identification.
The defence lawyer was also critical of other areas of the police investigation.
His client was described as wearing a green beanie and brown t-shirt but police never considered a search warrant to look for the garments.
"He genuinely denies being involved and considers the result to be a grave miscarriage of justice," Mr Mansfield said.
"He has been advised to proceed to an appeal and he will fight on. That is all you can do when it is considered the system has got it wrong."
According to a website, which lists the professionals in the heavily-regulated industry the defendant works, he is still working.
He will be sentenced next month.