none
WCF - Save SOAP request when datacontract don't match RRS feed

  • Question

  • Hi!

    I'm trying to save all requests to my WCF service. I configured Message Logging and I can save the request when I send to the service a correct XML. But if I send to the service a wrong XML the log is not saved.

    How can I save all request to the WCF? or is not possible to save the request if the cliente don't send a correct XML?

    For example, if I send to the service:

    <SOAP-ENV:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" <SOAP-ENV:Body> <ns1:cotizacion xmlns:ns1="Petroleo"> <op1 xsi:type="xsd:string"> Brent </op1> <op2 xsi:type="xsd:integer"> 400 </op2> </ns1:cotizacion> </SOAP-ENV:Body> </SOAP-ENV:Envelope>

    The Message Logging save the request. But if I change something in the Soap XML:

     <SOAP-ENV:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                 xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
    
           <SOAP-ENV:Body>
             <can:cotizacion xmlns:ns1="Petroleo">
               <op1 xsi:type="xsd:string"> Brent </op1>
               <op2 xsi:type="xsd:integer"> 400 </op2>
             </can:cotizacion>
           </SOAP-ENV:Body>
    
         </SOAP-ENV:Envelope>

    Element can don't match with the WCF WSDL and Message Logging don't save the request.

    Can't I save this kind of requests?

    Thanks a lor!

    Monday, October 3, 2016 6:45 PM

Answers

  • Hello Alberto,

    It sounds like you want to take control of the message logging and/or the validation of the message.  This sounds like a perfect job for a custom message inspector.  

    Here are a couple of posts that explains the steps well:

    https://blogs.msdn.microsoft.com/carlosfigueira/2011/04/18/wcf-extensibility-message-inspectors/

    http://patrickdesjardins.com/blog/wcf-inspector-for-logging


    Cheers, Jeff

    Monday, October 3, 2016 10:25 PM

All replies

  • Hello Alberto,

    It sounds like you want to take control of the message logging and/or the validation of the message.  This sounds like a perfect job for a custom message inspector.  

    Here are a couple of posts that explains the steps well:

    https://blogs.msdn.microsoft.com/carlosfigueira/2011/04/18/wcf-extensibility-message-inspectors/

    http://patrickdesjardins.com/blog/wcf-inspector-for-logging


    Cheers, Jeff

    Monday, October 3, 2016 10:25 PM
  • Hi, If it is logging for tracing that you need to include malformed messages, make sure that you have turned on logging at transport level  with logMalformedMessage also set to true as shown below

    <system.diagnostics>
      <sources>
          <source name="System.ServiceModel.MessageLogging">
            <listeners>
                     <add name="messages"
                     type="System.Diagnostics.XmlWriterTraceListener"
                     initializeData="messages.svclog" />
              </listeners>
          </source>
        </sources>
    </system.diagnostics>
    
    <system.serviceModel>
      <diagnostics>
        <messageLogging 
             logEntireMessage="true" 
             logMalformedMessages="true"
             logMessagesAtServiceLevel="true" 
             logMessagesAtTransportLevel="true"
             maxMessagesToLog="3000"
             maxSizeOfMessageToLog="2000"/>
      </diagnostics>
    </system.serviceModel>




    Tuesday, October 4, 2016 3:10 AM