I am trying to send a message via WCF and MSMQ and apply a transformation to the message content before it is sent.
I can capture the message in the BeforeSendRequest event of a Client Message Inspector, grab the message as xml and apply an Xslt transform to it that essentialy replaces a parameter value in the soap message that was null when the message was built. When the message arrives at that other endpoint though, the parameter is still null even though I've tried my best to insert a value into the message.
If I hard code the message to contain the expected parameter all works as expected, it only "fails" with a null value when I apply the transform. Don't know if I am doing something fundamentally wrong here (I'm new to most of these topics) or if my soap xml is just wrong.
I've looked at the xml created when I hard code the response and used this as the basis of my transform. I've inspected the message on the way out and in, fiddled with namespaces and googled to till I'm wiped out... any help would be greatly appreciated!
Here is the body part of the transformed message..
<s:Body>
<ImportClientOrders xmlns="urn:OrderServices.UI.Services/Contract/2013/05">
<clientOrderSourceId>2</clientOrderSourceId>
<clientOrderData xmlns="" xmlns:osCod="urn:OrderServices.UI.Services/Schemas/2013/05" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<osCod:OperationResult i:type="osXml:string" xmlns:osXml="http://www.w3.org/2001/XMLSchema">TestString</osCod:OperationResult>
<osCod:OperationSucceeded>true</osCod:OperationSucceeded>
</clientOrderData>
</ImportClientOrders>
In the transform I copy all nodes from the source message and replace the "clientOrderData" element with the xml shown above.
The target contract is as follows:
[ServiceContract(Namespace = "urn:OrderServices.UI.Services/Contract/2013/05")]
public interface IOrderManagementService
{
/// <summary>
/// Import new orders into the sytem and acknowledge them with the end client
/// </summary>
/// <param name="clientOrderSourceId"></param>
/// <param name="clientOrderData"></param>
[OperationContract(IsOneWay = true)]
void ImportClientOrders(int clientOrderSourceId, ClientOperationResult clientOrderData);
}
The Data contract for the ClientOperationResult is:
[DataContract(Namespace="urn:OrderServices.UI.Services/Schemas/2013/05")]
public class ClientOperationResult : IClientOperationResult
{
#region Implementation of IClientOperationResult
/// <summary>
/// Inidicates whether or not the operation was a success
/// </summary>
[DataMember]
public bool OperationSucceeded { get; set; }
/// <summary>
/// The result, if any of the operation
/// </summary>
[DataMember]
public object OperationResult { get; set; }
#endregion
}
Note that the OperationResult is type Object and at runtime I am supplying a string. Don't know if that has any bearing on this? Like I say it works if I supply a hard coded ClientOperationResult but not if I try and do the same with a transform.
Hope that's all clear. Thanks, W