"Untyped" receive ports in BizTalk Server 2004

Its not an uncommon request (in fact I got one in email today) to want to receive:

1. Non-XML data in a receive-port

2. XML messages of differing XML schemas within a single receive port

So how do you do that with BizTalk Server?

1. Set the messagetype property on your receive port to System.xml.xmldocument (yes I know in case 1 you are receiving non-XML data, but do it anyways)

2. Set-up a filter on the receive shape in orchestration which will pickup the message. Make sure you set your filter appropriately so you don't pick-up all documents.

To access the data as a stream (if you want) then you can use this in an expression shape: 

XLANGPart.RetrieveAs( typeof(Stream) )

Credits to Yossi