Search code examples
wcfwcf-data-servicesinterceptor

Getting message element through wcf intercepter


public object BeforeSendRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel)
    {
       MessageBuffer buffer = request.CreateBufferedCopy(Int32.MaxValue);
      Message reply = buffer.CreateMessage();
      XmlDocument NewbodyDoc = new XmlDocument();
      NewbodyDoc.Load(reply.ToString);
      XmlNodeList strval = NewbodyDoc.GetElementsByTagName("SSNIdentification");
        if (strval.Count > 0)
        {
            XmlNode xmlNode = strval.Item(0);

              string strRval = xmlNode.InnerText;}

I was trying to extract one element from the input message using WCF Interceptor. but i am getting error at Line NewbodyDoc.Load(reply.ToString);

Does any one has idea what am i doing wrong.


Solution

  • ToString() is a method and you have missed the angular braces

    Change this

     NewbodyDoc.Load(reply.ToString);
    

    To

     NewbodyDoc.Load(reply.ToString());
    

    Happy Coding :)