Came across something new today (imagine that!) I was packaging up a new release that adds, among other things, a send port going to an FTP site. The name of the target folder on the FTP site uses an ampersand (&, in case you don’t know ;-)). Well, my deployment scripts use XML binding files to bind all the orchestrations and set up the ports, so I went into the binding file to add the new info for the send port.
Of course, when adding the ampersand in XML it needs to be escaped. As in “&”. No problem. The SendPort in the binding file has two elements that contain the target folder name. Address and TransportTypeData. The ampersand in the Address element can just be escaped as normal. However, the ampersands in the TransportTypeData element (there are two instances in the element) cannot be escaped as normal. If you used a binding file before you know (or you can see) that the data in the TransportTypeData element is itself escaped XML which then gets read by BizTalk to set up the properties on the send port.
My first guess was to try escaping it “twice”, such as “&amp;”, with the hope that the first pass would result in “&” and the second pass would result in the desired “&”. The import wizard liked it, but when I tried going in to view the properties of the send port it came up and told me I had some invalid XML. Back to the guessing game.
Except sometimes I don’t like guessing. So I did it the way I should’ve in the first place. I set up the port through the BizTalk Explorer and ran an export on the assembly binding to see how BizTalk did it. Turns out it I was close, but needed to escape it one more time. The right way to do it is “&amp;amp;” Perhaps that’s an XML trick not specific to BizTalk, but I never came across it before.