Uso di pipeline dalla soluzione orientata ai servizi
La versione inline dell'orchestrazione del servizio clienti (CustomerService) chiama direttamente il sistema di rilevamento dei pagamenti. Per preparare il messaggio inviato ed elaborare quello ricevuto, l'orchestrazione chiama le pipeline dal codice. In questo modo è possibile riutilizzare le pipeline dalle altre versioni degli scenari. Viene inoltre mantenuta la separazione dell'orchestrazione dalle fasi delle pipeline.
Chiamata delle pipeline
Per utilizzare le pipeline dal codice, è necessario creare un insieme di messaggi, aggiungere all'insieme il messaggio da elaborare, creare un messaggio vuoto per ricevere il messaggio del risultato e richiamare la pipeline.
Il codice seguente dell'orchestrazione CustomerService si trova nella forma CostRequestMessageAfterSendPipeline :
// Create the collection of messages to be sent to the send pipeline...
sendPipelineInputMessages =
new Microsoft.XLANGs.Pipeline.SendPipelineInputMessages();
sendPipelineInputMessages.Add(LastPaymentRequest);
// Create an empty message for the output from the pipeline...
LastPaymentRequestAfterSendPipeline = null;
// Execute the send pipeline and get the message output from
// the send pipeline.
Microsoft.XLANGs.Pipeline.XLANGPipelineManager.
ExecuteSendPipeline(
typeof(
Microsoft.Samples.BizTalk.
WoodgroveBank.PaymentTrackerPipelines.
PaymentTrackerSendPipeline
),
sendPipelineInputMessages,
LastPaymentRequestAfterSendPipeline
);
La forma GetLastPaymentResponse accetta il messaggio dal codice precedente, lo invia al sistema di rilevamento dei pagamenti e elabora il messaggio restituito tramite la pipeline di ricezione:
// Execute the inline method to send the message to the
// Payment Tracking System and get the response.
// The response message received should be passed through the
// receive pipeline.
LastPaymentResponseBeforeReceivePipeline =
Microsoft.Samples.BizTalk.
WoodgroveBank.
PaymentTrackerCall.
PaymentTrackerCaller.
GetPaymeTrackerResponse
(
LastPaymentRequestAfterSendPipeline
);
// Execute the receive pipeline using the helper class so that we don't
// need to declare the non-serializable types involved.
// Set the documentspec name so the xml disassembler in the
// pipeline can resolve the schemas for the received message
// without ambiguity.
LastPaymentResponseBeforeReceivePipeline(XMLNORM.DocumentSpecName) =
"Microsoft.Samples.BizTalk.WoodgroveBank.Schemas.LastPaymentResponse, Microsoft.Samples.BizTalk.WoodgroveBank.Schemas, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5f57a322d27bc5fb";
// Create an empty response message and fill it in with the
// real response from the Payment Tracking System
LastPaymentResponse = null;
Microsoft.Samples.BizTalk.WoodgroveBank.Utilities.
ReceivePipelineHelper.CallReceivePipeLine (
typeof(
Microsoft.Samples.BizTalk.WoodgroveBank.
PaymentTrackerPipelines.PaymentTrackerReceivePipeline
),
LastPaymentResponseBeforeReceivePipeline,
LastPaymentResponse
);