A case in point is that my wife and I were married in Japan and then applied for a spouse visa for me for Taiwan, which does not have diplomatic relationships with either Japan or the US.
There is an American Institute in Taiwan which functions as a consulate and does the same services. Taiwan has similar institutes in Japan and the States. We went to the one in Japan and had my visa processed there.