Re: iPhone iMessage not working with Wi-Fi but works with cellular data
You may want to check Settings > Apps > Messages, then make sure iMessage is turned on.
If you are sending to non-Apple (eg: Android) users, text messages in the Messages app must use cellular.
Apple to Apple devices use wi-fi for iMessages if the signal is strong enough, else they use cellular as well.
More info: What is the difference between iMessage, RCS, and SMS/MMS? - Apple Support
If needed, check you can: Connect to Wi-Fi on your iPhone or iPad - Apple Support
and
Wi-fi Assist is generally on by default,(ie switches between cellular and wi-fi) yet can be turned off, or back on, as you wish:
More info: About Wi-Fi Assist - Apple Support
If you have difficulties with your wi-fi network: or accessing the internet, you can check for intrference:
See how to: Resolve Wi-Fi and Bluetooth issues caused by wireless interference - Apple Support