Custom XML Disassembler only ever returns one message
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > BizTalk Server > BizTalk Server General > Custom XML Disassembler only ever returns one message




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Custom XML Disassembler only ever returns one message  
Devon Cochenour


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-27-05 10:52 PM

I have created a custom disassembler that is being used to do some work on a
large XML file that is received and then parsed into many smaller docs, some
work done on those docs and then sent back to bts as many small docs.

I have gotten the code to run successfully, but all that ever happens is
that I only ever get ONE document back. Its the first one of the batch of
smaller documents, but thats it. I am at a loss as to what I am missing.

The code looks like this.

public IBaseMessage GetNext(IPipelineContext pContext)
{


return disassembler.GetNext(pContext);
}

public void Disassemble(IPipelineContext pContext, IBaseMessage pInMsg)
{
if (null == pContext)
throw new ArgumentNullException("pContext");

if (null == pInMsg)
throw new ArgumentNullException("pInMsg");


// Check whether input message doesn't have a body part or it is set to
null, fail probe in those cases
if (null == pInMsg.BodyPart || null ==
pInMsg.BodyPart.GetOriginalDataStream())
throw new ArgumentNullException("pInMessage","The inbound message has no
message body");

Stream sourceStream = pInMsg.BodyPart.GetOriginalDataStream();


try
{

IDocumentSpec documentSpec =
pContext.GetDocumentSpecByType("urn:mdWebService#ResponseRecord");

pInMsg.Context.Write(DocumentSpecNamePropertyName, "urn:mdWebService",
documentSpec.DocSpecStrongName);

originalMsgContext = PipelineUtil.CloneMessageContext(pInMsg.Context);

xmlDoc.Load(sourceStream);



if (xmlDoc != null)
{
XmlNodeList xmlNodeList = xmlDoc.GetElementsByTagName("ResponseRecord");

string sNodeData;


sNodeData = xmlNodeList.Item(i).OuterXml;

while(i<xmlNodeList.Count)
{

XmlDocument xmlNewDoc = new XmlDocument();
xmlNewDoc.LoadXml(sNodeData);
EventLog.WriteEntry("CASS_Orchestration",xmlNewDoc.OuterXml.ToString());

MemoryStream  newStream = new MemoryStream();

byte[] bData = System.Text.Encoding.UTF8.GetBytes(sNodeData);

newStream.Flush();

newStream.Write(bData,0,bData.Length);

newStream.Seek(0,SeekOrigin.Begin);

newMsg = pContext.GetMessageFactory().CreateMessage();

IBaseMessagePart newMsgPart =
pContext.GetMessageFactory().CreateMessagePart();

newMsgPart.Charset         = "UTF-8";

newMsgPart.Data            = newStream;

newMsg.AddPart("body", newMsgPart, true);

for (int iProp = 0; iProp < originalMsgContext.CountProperties; iProp++)

{

string strName;

string strNSpace;

object val = originalMsgContext.ReadAt(iProp, out strName, out
strNSpace);


if (originalMsgContext.IsPromoted(strName, strNSpace))

newMsg.Context.Promote(strName, strNSpace, val);

else

newMsg.Context.Write(strName, strNSpace, val);

}

pContext.ResourceTracker.AddResource(newStream);

i++;

disassembler.Disassemble(pContext,newMsg);


}
sourceStream.Seek(0,SeekOrigin.End);

}

}

--
Devon Cochenour
MCSD, MCT MSF Master Trainer






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 06:40 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register