Nimrod,
Your requirement is very typical in the EDI world. You should leverage B2B - TPM Profiles and Templates to meet your requirement. The way huge organizations set up their trading partners sometimes unfortunately is not with EDI routing on mind. They just assume the message broker can handle anything.
The best way to route the EDI docs is always a combination of WE20 parameters, Payload values (WE/AG etc. segments), User Exit (least preferable), Value Maps (TPM is better) and TPM.
If you are lucky you will use just WE20 config and SHIP-TO, SOLD-TO segments. Next option is TPM Profiles and Templates with UDFTPMPool libraries to do the look up.