示例#1
0
 public void Execute(ref IBaseMessage inmsg, IPipelineContext pc)
 {
     if (detailType == PartDetailTypeEnum.CharSet)
     {
         inmsg.GetPart(partName).Charset = value;
     }
     else if (detailType == PartDetailTypeEnum.ContentType)
     {
         inmsg.GetPart(partName).ContentType = value;
     }
 }
示例#2
0
 public void Execute(ref IBaseMessage inmsg, IPipelineContext pc)
 {
     try
     {
         if (castRequired)
         {
             inmsg.GetPart(partName).PartProperties.Write(propertyName, propertyNamespace, TypeCaster.GetTypedObject(value, type));
         }
         else
         {
             inmsg.GetPart(partName).PartProperties.Write(propertyName, propertyNamespace, value);
         }
     }
     catch (Exception e)
     {
         throw new Exception("Unable to set part property " + propertyNamespace + "#" + propertyName + " on message part " + partName
                             + ". Encountered error - " + e.ToString());
     }
 }
示例#3
0
        public void CanCreateMultipartMessage()
        {
            string body = "<body>Some message content</body>";

            IBaseMessage message = MessageHelper.CreateFromString(body);

            Assert.IsNotNull(message);
            Assert.IsNotNull(message.BodyPart);
            Assert.IsNotNull(message.BodyPart.Data);
            Assert.IsTrue(message.BodyPart.Data.Length > 0);

            IBaseMessagePart part1 = MessageHelper.CreatePartFromString(body);

            message.AddPart("part1", part1, false);
            Assert.AreEqual(2, message.PartCount);
            Assert.IsNotNull(message.GetPart("part1"));
        }
示例#4
0
 /// <summary>
 /// Returns a response message part from the specified message.
 /// </summary>
 /// <param name="msg">The message instance represented by the <see cref="Microsoft.BizTalk.Message.Interop.IBaseMessage"/> object.</param>
 /// <returns>The response message part represented by the <see cref="Microsoft.BizTalk.Message.Interop.IBaseMessagePart"/> object.</returns>
 public static IBaseMessagePart GetResponsePart(IBaseMessage msg)
 {
     return(ContainsResponsePart(msg) ? msg.GetPart(Resources.ResponseBodyPartName) : null);
 }
示例#5
0
        /// <summary>
        /// Verifies whether or not the specified message contains a response message part.
        /// </summary>
        /// <param name="msg">The message instance represented by the <see cref="Microsoft.BizTalk.Message.Interop.IBaseMessage"/> object.</param>
        /// <returns>True if response message part was found, otherwise false.</returns>
        public static bool ContainsResponsePart(IBaseMessage msg)
        {
            Guard.ArgumentNotNull(msg, "msg");

            return(msg.GetPart(Resources.ResponseBodyPartName) != null);
        }
        private IBaseMessage BuildResponseMessage(IBaseMessage message, IBaseMessageContext context, LoopBackTransmitProperties props)
        {
            Guid callToken  = TraceManager.CustomComponent.TraceIn();
            long startScope = TraceManager.CustomComponent.TraceStartScope("BuildResponseMessage", callToken);

            IBaseMessageFactory messageFactory = _transportProxy.GetMessageFactory();
            IBaseMessage        btsResponse    = messageFactory.CreateMessage();

            TraceManager.CustomComponent.TraceInfo("PropertyCopy: {0}", props.PropertyCopy);
            if (props.PropertyCopy)
            {
                btsResponse.Context = PipelineUtil.CloneMessageContext(context);
            }
            TraceManager.CustomComponent.TraceInfo("CustomPropertyCopy: {0}", props.CustomPropertyCopy);
            if (props.CustomPropertyCopy)
            {
                btsResponse.Context = messageFactory.CreateMessageContext();
                for (int i = 0; i < context.CountProperties; i++)
                {
                    string strName;
                    string strNamespace;
                    object oValue = context.ReadAt(i, out strName, out strNamespace);
                    if (!strNamespace.StartsWith("http://schemas.microsoft.com/BizTalk"))
                    {
                        if (context.IsPromoted(strName, strNamespace))
                        {
                            TraceManager.CustomComponent.TraceInfo("Promoted into context: {1}#{0}={2}", strName, strNamespace, oValue);
                            btsResponse.Context.Promote(strName, strNamespace, oValue);
                        }
                        else
                        {
                            TraceManager.CustomComponent.TraceInfo("Copied into context: {1}#{0}={2}", strName, strNamespace, oValue);
                            btsResponse.Context.Write(strName, strNamespace, oValue);
                        }
                    }
                }
            }
            TraceManager.CustomComponent.TraceInfo("PartCount: {0}", message.PartCount);
            for (int i = 0; i < message.PartCount; i++)
            {
                string        str;
                VirtualStream stream = new VirtualStream();
                StreamReader  rdr    = new StreamReader(message.GetPartByIndex(i, out str).GetOriginalDataStream(), true);
                StreamWriter  wrtr   = new StreamWriter(stream, rdr.CurrentEncoding);
                wrtr.Write(rdr.ReadToEnd());
                rdr.Close();
                wrtr.Flush();
                stream.Seek(0, SeekOrigin.Begin);
                IBaseMessagePart part = messageFactory.CreateMessagePart();
                if (props.PropertyCopy)
                {
                    part.Charset        = message.GetPart(str).Charset;
                    part.ContentType    = message.GetPart(str).ContentType;
                    part.PartProperties = PipelineUtil.CopyPropertyBag(message.GetPart(str).PartProperties, messageFactory);
                }
                btsResponse.AddPart(str, part, message.GetPart(str).PartID.Equals(message.BodyPart.PartID));
                btsResponse.GetPart(str).Data = stream;
            }

            TraceManager.CustomComponent.TraceEndScope("BuildResponseMessage", startScope, callToken);
            TraceManager.CustomComponent.TraceOut(callToken);

            return(btsResponse);
        }