Yes--I am using the EDI Disassembler later in the pipeline. I've also tried specifying the message content type and charset, but still getting the same error. Here is the custom component code:
public IBaseMessage Execute(IPipelineContext pc, IBaseMessage pInMsg)<o:p></o:p>
{<o:p></o:p>
try<o:p></o:p>
{<o:p></o:p>
IBaseMessagePart bodyPart = pInMsg.BodyPart;<o:p></o:p>
if (bodyPart != null)<o:p></o:p>
{<o:p></o:p>
int bufferSize = 0x280;<o:p></o:p>
int thresholdSize = 0x100000;<o:p></o:p>
Stream inStream = pInMsg.BodyPart.GetOriginalDataStream();<o:p></o:p>
VirtualStream vStream = new VirtualStream(bufferSize, thresholdSize);<o:p></o:p>
ReadOnlySeekableStream rosStream = new ReadOnlySeekableStream(inStream, vStream, bufferSize);<o:p></o:p>
XmlTextReader xmlTR = new XmlTextReader(rosStream);<o:p></o:p>
XPathCollection xpCollection = new XPathCollection();<o:p></o:p>
xpCollection.NamespaceManager = new XmlNamespaceManager(new NameTable());<o:p></o:p>
xpCollection.Add(this._XPath);<o:p></o:p>
XPathReader xpReader = new XPathReader(xmlTR, xpCollection);<o:p></o:p>
bool found = false;<o:p></o:p>
while (xpReader.ReadUntilMatch())<o:p></o:p>
{<o:p></o:p>
if (xpReader.Match(0) && !found)<o:p></o:p>
{<o:p></o:p>
newMessageBody = xpReader.ReadElementContentAsString();<o:p></o:p>
newMessageBody = newMessageBody.Trim();<o:p></o:p>
found = true;<o:p></o:p>
}<o:p></o:p>
}<o:p></o:p>
byte[] msgArray = Encoding.ASCII.GetBytes(newMessageBody);<o:p></o:p>
MemoryStream mStream = new MemoryStream(msgArray);<o:p></o:p>
pInMsg.BodyPart.Data = mStream;<o:p></o:p>
pInMsg.BodyPart.ContentType = "Text";<o:p></o:p>
pInMsg.BodyPart.Charset = "ASCII";<o:p></o:p>
mStream.Position = 0;<o:p></o:p>
}<o:p></o:p>
}<o:p></o:p>
catch (Exception ex)<o:p></o:p>
{<o:p></o:p>
if (pInMsg != null)<o:p></o:p>
{<o:p></o:p>
pInMsg.SetErrorInfo(ex);<o:p></o:p>
}<o:p></o:p>
throw ex;<o:p></o:p>
}<o:p></o:p>
return pInMsg;<o:p></o:p>
}
Nothing really stands out.
Do need to force the content to ASCII? I would just use a StreamWriter to write the output of .ReadElementContentAsString() directly to the MemoryStream. That will preserve the encoding.
Have you tried without the EDI Disassembler? Just to check this component output?
- Edited by Johns-305 [boatseller]MVP 8 hours 45 minutes ago
Nothing really stands out.
Do need to force the content to ASCII? I would just use a StreamWriter to write the output of .ReadElementContentAsString() directly to the MemoryStream. That will preserve the encoding.
Have you tried without the EDI Disassembler? Just to check this component output?
- Edited by Johns-305 [boatseller]MVP Wednesday, April 29, 2015 10:18 PM
Nothing really stands out.
Do need to force the content to ASCII? I would just use a StreamWriter to write the output of .ReadElementContentAsString() directly to the MemoryStream. That will preserve the encoding.
Have you tried without the EDI Disassembler? Just to check this component output?
- Edited by Johns-305 [boatseller]MVP Wednesday, April 29, 2015 10:18 PM
Nothing really stands out.
Do need to force the content to ASCII? I would just use a StreamWriter to write the output of .ReadElementContentAsString() directly to the MemoryStream. That will preserve the encoding.
Have you tried without the EDI Disassembler? Just to check this component output?
- Edited by Johns-305 [boatseller]MVP Wednesday, April 29, 2015 10:18 PM
- Marked as answer by Angie xuMicrosoft contingent staff, Moderator 5 hours 26 minutes ago
- Marked as answer by Angie xuMicrosoft contingent staff, Moderator Wednesday, May 06, 2015 1:38 AM