Quick C# and SOAP expert for a small piece of source code

Job ID: 32163408

Budget: $10 – $30 USD

It should be simple for someone who knows C# and concept of SOAP

Replace the Message (System.ServiceModel.Channels) content with altered soap xml. If any xml element of SOAP message in the "ref Message reply" paramte has a value of "0E-number" eg: 0E-7 then replace it with 0 and update the "ref Message reply" paramter, You should retain the same xml format. Just replace only those values if found.

/// <summary>
/// Allows adding in WS-Security header to incoming request
/// </summary>
public class TestMessageInspector : IClientMessageInspector
{
.......
public void AfterReceiveReply(ref Message reply, object correlationState)
{
// Here Need to replace or alter the reply Message (System.ServiceModel.Channels) content with other soap xml. Tried the below code and it does not alter the reply message content
var sb = new StringBuilder("<testAmt>88977</testAmt>");
using (var sw = XmlWriter.Create(new StringWriter(sb)))
{
reply.WriteMessage(sw);
sw.Flush();
} }
}

Sample Input:
<? xml version='1.0' encoding='utf-16'?><SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'><SOAP-ENV:Header/><SOAP-ENV:Body>< ns4:testResponse xmlns:ns2 = 'http://www.seconddecimal.com/ncsts/schemas/unrestricted/messages' xmlns:ns4 ='http://www.seconddecimal.com/ncsts/schemas/messages'><Document><testAmt >0E-7</testAmt><testRate>0</testRate><test1Amt>0E-8</test1Amt></Document></ns4:testResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>

Sample Output:

<? xml version='1.0' encoding='utf-16'?><SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'><SOAP-ENV:Header/><SOAP-ENV:Body>< ns4:testResponse xmlns:ns2 = 'http://www.seconddecimal.com/ncsts/schemas/unrestricted/messages' xmlns:ns4 ='http://www.seconddecimal.com/ncsts/schemas/messages'><Document><testAmt >0</testAmt><testRate>0</testRate><test1Amt>0</test1Amt></Document></ns4:testResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
Related categories: XML .NET C# Programming