/ Published in: C#
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
public class CreateExtension : IEndpointBehaviorExtender { #region IEndpointBehaviorExtender Members public string Action { get { return "Expense/Create"; } } public void BeforeSendRequest(string action, ref Message request, IDictionary<string, object> formData) { // create a strongly type version of the message ExpenseCreateRequestMessage req = MessageConverter<ExpenseCreateRequestMessage>.GetObjectFromMessage(action, request); // the data contract already has additonal collections (dictionaries) so that // additional data can be stored along with the default contract. // Try to make 'key' as unique as possible so that only you could identify it. Perhaps add your name / intials or BP Channel Name if (!req.Expense.FieldExtensions.ContainsKey("RBC_DateExpenseCreated")) req.Expense.FieldExtensions.Add("RBC_DateExpenseCreated", DateTime.Now.ToLongDateString()); // replace the message request with new one request = MessageConverter<ExpenseCreateRequestMessage>.SetMessageFromObject(action, req, request.Headers.MessageVersion); } public void AfterReceiveReply(string action, Message reply) { // convert the message to its strong type (as described in contract library) ExpenseCreateResponseMessage response = MessageConverter<ExpenseCreateResponseMessage>.GetObjectFromMessage(action, reply); // do stuff with respones... } #endregion }