A while back I wrote about a problem I encountered where my client’s system is experiencing “Object not set to a reference of an object” errors in the receive pipeline for one of their client. After yet another round of experimentation, I FINALLY figured out what caused it!
This particular client appear to programmatically connect to the BizTalk server via Telnet as a way to keep the socket open. In return, BizTalk would treat the connection as having a missing body (not to be confused with an empty body). To solve the problem, although it’s not ideal, is to put a try/catch around the GetOriginalDataStream() and return null if it encounters an error. Unfortunately, the side affect of this is an active blank message instance in the BizTalk Administration Console. But at least there are no more error event logs and suspended message instances.
public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg) { IBaseMessagePart msgBody = pInMsg.BodyPart;
if (msgBody != null) {
string oldStr = string.Empty; try { using (StreamReader sr = new StreamReader(msgBody.GetOriginalDataStream())) { oldStr = sr.ReadToEnd(); } } catch { return null; } << INSERT STUFF YOU NEED TO DO HERE>>
}
}
