I've found a William H Foster going to Shanghai in October 1922 with a wife Lillian so I'm not sure that the death that we've found would be your Willam's as both his birth and marriage records record him as just William and, as the Consular indexes are in blocks of years, the ref could be anytime between 1921 and 1925.
Gadget