The answer to that question can be found at Quora.com: https://www.quora.com/How-did-Sigmund-Freud-and-William-James-opinion-on-religion-differ .
To put it in the simplest terms, Sigmund Freud stated clearly he saw religion as pathological and studied it as a kind of mental disorder. *How I like that explanation.*
William James on the other hand saw the religious feeling as a legitimate part of human mentally, something to be understood and studied and not dismissed. *In a way, I like that explanation too.*
William James became famous as the psychologist who studied the religious experience, Sigmund Freud only dismissed it.