EDI receive on Http adapter solicit/response port
I have an orchestration that sends a request message on an http solicit/response port.  The response message has EDI data in one of the nodes.  I have a custom pipeline component that extracts the EDI data from that node and attempts to return it as the message.  I am getting an error:  Data at the root level is invalid.  Line 1, position 2067.  Is it possible to do this or should I look at another approach?
April 29th, 2015 1:22pm

If you're extracting the EDI, then you shouldn't be using the XmlDisassembler later in the Pipeline.  Use either the EDI Disassembler or no disassembler.
Free Windows Admin Tool Kit Click here and download it now
April 29th, 2015 3:13pm

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>

}

April 29th, 2015 5:36pm

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?


Free Windows Admin Tool Kit Click here and download it now
April 29th, 2015 6:20pm

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?


April 29th, 2015 10:18pm

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?


Free Windows Admin Tool Kit Click here and download it now
April 29th, 2015 10:18pm

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?


April 29th, 2015 10:18pm

I got it working.  I think the problem was that I have another pipeline component in front of this one and the stream from that was not being reset to 0.
Free Windows Admin Tool Kit Click here and download it now
April 30th, 2015 3:14pm

I got it working.  I think the problem was that I have another pipeline component in front of this one and the stream from that was not being reset to 0.
April 30th, 2015 7:11pm

I got it working.  I think the problem was that I have another pipeline component in front of this one and the stream from that was not being reset to 0.
Free Windows Admin Tool Kit Click here and download it now
April 30th, 2015 7:11pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics