Of course it would be legal and binding because it has been passed through parliament.
A parliamentary decision to hold a referendum does not mean that the result is binding. Parliament can decide to hold an advisory referendum - in other words it allows them to gauge the view of the public but without being bound to accept that view and act according to its outcome.
Currently I am not sure what the nature of the referendum that may be held in the summer will be - indeed I don't know whether it has actually gone through parliament yet.
CORRECTION - the European Union Referendum Act 2015 received royal ascent in December, but I think this only allows the referendum to be held, I am not sure it binds the government to its outcome.