2013-06-26 31 views
5

tôi đã giải quyết được tên truy cập và mật khẩu đăng nhập thông qua cấu hình với các liên kết giúp đỡwcf tất cả nội dung thư trong tệp .svclog luôn là "<env:Body> ... luồng ...</env:Body>", cách hiển thị nội dung thực thông qua cấu hình?

Mối quan tâm bảo mật cho tin nhắn Logging http://msdn.microsoft.com/en-us/library/ms730318.aspx

nhưng nội dung thư luôn là "... suối ...",

là có cách nào để giải quyết điều này thông qua cấu hình hoặc làm nó programaticly?

tôi chỉ muốn xem "yêu cầu/phản hồi chi tiết xà phòng xml" bằng công cụ SvcTraceViewer.


tôi đã thấy cả tiêu đề thư và body.my vấn đề là >>> cơ thể luôn luôn là như "... suối ...", tôi cần những nội dung thực sự không chỉ là" .. . suối ...".


thông điệp yêu cầu

<MessageLogTraceRecord> 
    <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"> 
    <s:Header> 
    <Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://www.onvif.org/ver10/device/wsdl/GetSystemDateAndTime</Action> 
    <ActivityId CorrelationId="fcc87310-055d-452b-9c0d-ffe671585392" xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">4876b839-30d4-4351-abb8-4fa6bf53d7e1</ActivityId> 
    <VsDebuggerCausalityData xmlns="http://schemas.microsoft.com/vstudio/diagnostics/servicemodelsink"></VsDebuggerCausalityData> 
    <Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> 
    <UsernameToken> 
    <Username>duwu891229</Username> 
    <Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">1ax8Hp9OY1H+vw7+w0fv8BDps9M=</Password> 
    <Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">V5x7WKzZ4U2DdM9cxhVXuQEAAAAAAA==</Nonce> 
    <Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2013-06-26T05:50:06.006Z</Created> 
    </UsernameToken> 
    </Security> 
    </s:Header> 
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    <GetSystemDateAndTime xmlns="http://www.onvif.org/ver10/device/wsdl"></GetSystemDateAndTime> 
    </s:Body> 
    </s:Envelope> 
    </MessageLogTraceRecord> 

nhắn phản ứng (vấn đề trong "env: Body" tag)

<MessageLogTraceRecord> 
    <HttpResponse xmlns="http://schemas.microsoft.com/2004/06/ServiceModel/Management/MessageTrace"> 
    <StatusCode>OK</StatusCode> 
    <StatusDescription>OK</StatusDescription> 
    <WebHeaders> 
    <Date>Wed, 26 Jun 2013 13:50:06 GMT</Date> 
    <Server>App-webs/</Server> 
    <Connection>close</Connection> 
    <Content-Length>2406</Content-Length> 
    <Content-Type>application/soap+xml; charset=utf-8</Content-Type> 
    </WebHeaders> 
    </HttpResponse> 
    <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:soapenc="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl" xmlns:tst="http://www.onvif.org/ver10/storage/wsdl" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:dn="http://www.onvif.org/ver10/network/wsdl" xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl" xmlns:wsoap12="http://schemas.xmlsoap.org/wsdl/soap12" xmlns:http="http://schemas.xmlsoap.org/wsdl/http" xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:wsadis="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:wsrf-bf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wsntw="http://docs.oasis-open.org/wsn/bw-2" xmlns:wsrf-rw="http://docs.oasis-open.org/wsrf/rw-2" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsrf-r="http://docs.oasis-open.org/wsrf/r-2" xmlns:tnshik="http://www.hikvision.com/2011/event/topics"> 
    <env:Header></env:Header> 
    <env:Body>... stream ...</env:Body> 
    </env:Envelope> 
    </MessageLogTraceRecord> 

Machine.config

<configuration> 
    <system.serviceModel> 

      <machineSettings enableLoggingKnownPii="true" /> 

    </system.serviceModel> 

    </configuration> 

app.config

<system.diagnostics> 
    <sources> 
     <source name="System.ServiceModel" 
       switchValue="Information, ActivityTracing" 
       propagateActivity="true"> 
     <listeners> 
      <add name="xml"/> 
     </listeners> 
     </source> 
     <source name="System.ServiceModel.MessageLogging" 
       switchValue="Information, ActivityTracing" 
       logKnownPii="true"> 
     <listeners> 
      <add name="xml"/> 
     </listeners> 
     </source> 
     <source name="myUserTraceSource" 
       switchValue="All"> 
     <listeners> 
      <add name="xml"/> 
     </listeners> 
     </source> 
    </sources> 

    <sharedListeners> 
     <add name="xml" 
      type="System.Diagnostics.XmlWriterTraceListener" 
       initializeData="log\wcf.svclog" /> 
    </sharedListeners> 

    <trace autoflush="true" indentsize="2"> 
     <listeners> 
     <!--<clear />--> 
     <add type="System.Diagnostics.ConsoleTraceListener" name="console"/> 
     </listeners> 
    </trace> 

    </system.diagnostics> 


    <system.serviceModel> 

    <diagnostics wmiProviderEnabled="true"> 
     <messageLogging logEntireMessage="true" logKnownPii="true" logMalformedMessages="true" 
     logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" 
     maxMessagesToLog="3000" /> 
    </diagnostics> 
    </system.serviceModel> 

Trả lời

4

Vâng, WCF tracing không đăng nhập toàn bộ thông điệp theo mặc định (chỉ xà phòng tiêu đề)

Có rất nhiều tùy chọn để cấu hình WCF tracing.

logEntireMessage: chỉ định xem toàn bộ thông báo (tiêu đề thư và nội dung) có được ghi nhật ký hay không. Giá trị mặc định là sai, có nghĩa là chỉ có tiêu đề được ghi lại.

maxMessagesĐể đăng nhập: chỉ định số lượng thư tối đa để ghi nhật ký. Khi đạt đến hạn ngạch, một dấu vết được phát ra và không có thông báo bổ sung nào được ghi lại. Giá trị mặc định là 10000.

maxSizeOfMessageToLog: chỉ định kích thước tối đa của thư để đăng nhập byte. Các thư vượt quá giới hạn kích thước sẽ không được ghi lại. Giá trị mặc định cho thông báo mức dịch vụ và mức truyền tải là 256K, trong khi giá trị mặc định cho tin nhắn không đúng định dạng là 4K.

Một cấu hình rất cơ bản là

<system.diagnostics> 
    <sources> 
     <source name="System.ServiceModel.MessageLogging"> 
     <listeners> 
       <add name="messages" 
       type="System.Diagnostics.XmlWriterTraceListener" 
       initializeData="c:\logs\messages.svclog" /> 
      </listeners> 
     </source> 
    </sources> 
</system.diagnostics> 

<system.serviceModel> 
    <diagnostics> 
    <messageLogging 
     logEntireMessage="true" 
     logMalformedMessages="false" 
     logMessagesAtServiceLevel="true" 
     logMessagesAtTransportLevel="false" 
     maxMessagesToLog="3000" 
     maxSizeOfMessageToLog="2000"/> 
    </diagnostics> 
</system.serviceModel> 

Edit:

Bạn đang sử dụng Streaming?Trên các thư đã phát, chỉ các tiêu đề được ghi lại. Bạn không thể thay đổi điều này. Để xem nội dung nội dung, tùy chọn duy nhất của bạn quá vô hiệu hóa phát trực tuyến.

Thay đổi TransferMode tài sản trong configuraiton ràng buộc của bạn (dịch vụ & client) để đệm.

+0

nhờ trả lời, nhưng bạn có thể hiểu lầm vấn đề của tôi, tôi đã tải lên mẫu mã để hiển thị các vấn đề một cách chính xác. – user2522745

+0

@ user2522745 xem chỉnh sửa – Cybermaxs

+0

oh tuyệt vời. tôi thay đổi "transport.TransferMode <-TransferMode.StreamedResponse" thành "transport.TransferMode <- TransferMode.Buffered" trong mã, giải quyết vấn đề. – user2522745

0

Có tùy chọn ghi nhật ký ... nội dung thư .... Ở cấp độ Dịch vụ, luồng không được ghi lại nhưng tại giao thông, toàn bộ cơ thể có thể được ghi lại.

Sử dụng logMessagesAtTransportLevel = "true"

<system.serviceModel> 
     <diagnostics> 
     <messageLogging 
      logEntireMessage="true" 
      logMalformedMessages="false" 
      logMessagesAtServiceLevel="true" 
      logMessagesAtTransportLevel="true" 
      maxMessagesToLog="3000" 
      maxSizeOfMessageToLog="2000"/> 
     </diagnostics> 
    </system.serviceModel> 
Các vấn đề liên quan