我在編排中的消息分配形狀中收到此錯誤。在這個賦值形狀中,我試圖執行XPath查詢以從WCF收到的消息中提取base64編碼的字符串。然後,我試圖加載一個XmlDocument變量,其中包含一個由我編寫的helper類生成的Stream。 base64字符串將是PDF或Excel文件的內容(注意:這不是XML)。我讀過這可以完成。BizTalk消息'<MessageName>'的零件'部分'包含零字節的數據
這裏是我的消息分配使用的表達:
messageCreator = new IAS.Integration.Services.Helpers.MessageCreator();
System.Diagnostics.EventLog.WriteEntry("IAS.Integration.Services.Orchestration", "MessageCreator Object created");
base64 = xpath(PerformTransformationResponse, "string(/*[local-name()='PerformTransformationResponseWrapper' and namespace-uri()='http://www.iasreo.com/integration/servicetypes']/*[local-name()='TransformedPayload'])");
//System.Diagnostics.EventLog.WriteEntry("IAS.Integration.Services.Orchestration", System.String.Format("Base64 from xpath: {0}", base64));
Output = new System.Xml.XmlDocument();
System.Diagnostics.EventLog.WriteEntry("IAS.Integration.Services.Orchestration", "Output instantiated as XmlDocument");
messageCreator.CreateMyMessage(Output, base64);
System.Diagnostics.EventLog.WriteEntry("IAS.Integration.Services.Orchestration", "messageCreator.CreateMyMessage(Output, base64)");
下面是我寫來支持這種表達的輔助類:
[Serializable]
public class MessageCreator
{
public void CreateMyMessage(XLANGMessage outMessage, string binaryStringMessage)
{
outMessage[0].LoadFrom(new StreamFactory(binaryStringMessage));
}
}
[Serializable]
public class StreamFactory : IStreamFactory
{
private string messageContent;
public StreamFactory(string inMessageContent)
{
messageContent = inMessageContent;
}
public Stream CreateStream()
{
byte[] messageBytes = Convert.FromBase64String(messageContent);
return new MemoryStream(messageBytes, 0, messageBytes.Length, true, true);
}
}
最後,這是我收到的錯誤在事件查看器中:
xlang/s引擎事件日誌條目:未捕獲的異常(請參閱下面的內部異常)已掛起創建了一個服務實例'IAS.Integration.Services.Orchestrations.MainOrchestration(fcad6d68-ce54-bfa2-d035-56608b99ef52)'。 服務實例將保持掛起狀態,直到管理性恢復或終止。 如果恢復,實例將從最後一個持久狀態繼續,並可能重新拋出相同的意外異常。 INSTANCEID:c398fd2a-b654-4981-be13-94146d640375 形狀名:Send_StreamedDocument ShapeId:bc7a463b-eed2-4222-b2f7-3fdb1e44a3c5 異常來自拋出:段1,進度25 內部異常:消息的部分 '部分' '輸出'包含零字節的數據。
異常類型:EmptyPartException 來源:Microsoft.XLANGs.Engine 目標站點:System.IO.Stream留存(System.String爲ByRef,布爾值) 以下是標識了異常出現 位置的堆棧跟蹤在Microsoft.XLANGs.Core.Part.Persist(字符串&編碼,布爾wantEncoding) 在Microsoft.BizTalk.XLANGs.BTXEngine.BTXXlangStore.StagePartData(第一部分的部分) 在Microsoft.BizTalk.XLANGs.BTXEngine.BTXXlangStore.PrepareMessage(XLANGMessage msg,IList promoteProps,IList toPromote) at Microsoft.BizTalk.XLANGs.BTXEngine.BTXXlangStore.WriteMessageState(IBTPEPInfoLookup pepLookup,Guid portId,XLANGMe在Microsoft.BizTalk.XLANGs.BTXEngine.BTXLogicalPortBinding.SendMessage(XLANGMessage msg,XlangStore存儲,Segment seg,OperationInfo op,IList additionalProps,IList提示, IList toPromote,Boolean ignoreRoutingFailure) at Microsoft.BizTalk.XLANGs.BTXEngine.BTXPortBase.SendMessage(Int32 iOperation,XLANGMessage msg,Correlation [] initCorrelations,Correlation [] followCorrelations,Context cxt,Segment seg,ActivityFlags flags) at IAS.Integration .Services.Orchestrations.MainOrchestration.segment1(StopConditions stopOn) 在Microsoft.XLANGs.Core.SegmentScheduler.RunASegment(段S,StopConditions stopCond,異常& EXP)**