Biztalk navigation
Generellt | Orkestrering | Mappning | XSLT | Scheman | Pipelines | Annat - Bindings, Adapters..

Custom pipeline functoid/komponent
Lägg DLL i C:\Program Files (x86)\Microsoft BizTalk Server\Pipeline Components (eller GAC:a)
Högerklicka på Biztalk Pipeline Components toolbox menyn i Visual Studio för att lägga till den

BodyPart stream to string
Stream originalStream = pInMsg.BodyPart.GetOriginalDataStream();
originalStream.Position = 0;
using (StreamReader reader = new StreamReader(originalStream, Encoding.UTF8))
{
    xmlString = reader.ReadToEnd();
}

String back to stream
return new MemoryStream(Encoding.UTF8.GetBytes(newString ?? ""));

Skriv över context värde / promote:a context värde
pInMsg.Context.Write("Username", "", reader["CurrentId"]);
pInMsg.Context.Promote("Username", "", reader["CurrentId"]);

Klona message Context
msg.Context = PipelineUtil.CloneMessageContext(sourceContext);

Pipeline.exe
Pipeline.exe ReceivePipeline.btp –d file_in.xml –s MySchema.xsd:MyProject.MySchema -c  

Visual Studio - Komponent i pipeline - ändrade parametrar visas inte
Ta bort .vs mappen för projektet och starta om Visual Studio
    
Bindings från komponent
// Det går både att läsa och skriva till dessa
pInMsg.Context.Read("OutboundTransportLocation", "")
// Ändra send port adress (även filsökväg om det är FILE adapter)
pInMsg.Context.Write("OutboundTransportLocation", "", constructedUrl);
pInMsg.Context.Write("OutboundTransportType", "", "WCF-WebHttp");
// Avancerat
// Ändra från HTTP till HTTPS
pInMsg.Context.Write("SecurityMode", "", 1);
pInMsg.Context.Write("HttpsTransportSecurityMode", "", 1);
pInMsg.Context.Write("HttpMethodAndUrl", "", HttpMethod);
pInMsg.Context.Write("HttpHeaders", "", formatedHeaders);
pInMsg.Context.Write("ProxyToUse", "", "UserSpecified");
pInMsg.Context.Write("ProxyAddress", "", Proxy);
pInMsg.Context.Write("ProxyUserName", "", ProxyUsername);
pInMsg.Context.Write("ProxyPassword", "", ProxyPassword);
pInMsg.Context.Write("SecurityMode", "", "Transport");
pInMsg.Context.Write("TransportClientCredentialType", "", "None");
pInMsg.Context.Write("MaxReceivedMessageSize", "", MaxReceivedMessageSize);
pInMsg.Context.Write("RetryCount", "", RetryCount);
// ReceivedFileName
pInMsg.Context.Write("ReceivedFileName", "", NEWNAME);


Mata BizTalk med flera meddelanden
// Receive Disassemble Component
public void Disassemble(Microsoft.BizTalk.Component.Interop.IPipelineContext pc, Microsoft.BizTalk.Message.Interop.IBaseMessage inmsg)
{
    IBaseMessageContext sourceContext = inmsg.Context;
    IBaseMessagePart part = inmsg.BodyPart;
    // queue four messages to be processed in the GetNext() method.
    // \\\\_msgs is a simple Queue
    \\\\_msgs.Enqueue(CreateMessage(pc, sourceContext,part));
    \\\\_msgs.Enqueue(CreateMessage(pc, sourceContext,part));
    \\\\_msgs.Enqueue(CreateMessage(pc, sourceContext,part));
    \\\\_msgs.Enqueue(CreateMessage(pc, sourceContext,part));
}
public IBaseMessage CreateMessage(IPipelineContext pc, IBaseMessageContext sourceContext, IBaseMessagePart part)
{
    IBaseMessage msg = pc.GetMessageFactory().CreateMessage();
    msg.AddPart("Body", part, true);
    // comment out the following line to preserve the original message
    msg.BodyPart.Data = new MemoryStream(ASCIIEncoding.ASCII.GetBytes("blah blah blah"));
    msg.Context = PipelineUtil.CloneMessageContext(sourceContext);
    msg.Context.Promote("MessageType", systemPropertiesNamespace, messageType);
    return msg;
}