我通过配置帮助链接解决了日志用户名和密码问题
对于消息记录安全顾虑 http://msdn.microsoft.com/en-us/library/ms730318.aspx
但是邮件正文总是"......流...",
有没有办法通过配置解决这个问题或以编程方式进行解决?
我只是想看看使用SvcTraceViewer工具"请求/响应详细的肥皂xml".
我已经看到了这两个消息头和body.my问题在于>>>身体总是喜欢"......流......",我需要真正的内容不只是"... ...流".
请求消息
<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>
Run Code Online (Sandbox Code Playgroud)
响应消息("env:Body"标记中的问题)
<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>
Run Code Online (Sandbox Code Playgroud)
machine.config中
<configuration>
<system.serviceModel>
<machineSettings enableLoggingKnownPii="true" />
</system.serviceModel>
</configuration>
Run Code Online (Sandbox Code Playgroud)
的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>
Run Code Online (Sandbox Code Playgroud)
是的,WCF 跟踪默认情况下不记录整个消息(仅肥皂头)
有许多选项可用于配置 WCF 跟踪。
logEntireMessage:指定是否记录整个消息(消息头和正文)。默认值为 false,表示仅记录标头。
maxMessagesToLog:指定要记录的最大消息数。达到配额时,会发出跟踪,并且不会记录其他消息。默认值为 10000。
maxSizeOfMessageToLog:指定要记录的消息的最大大小(以字节为单位)。超过大小限制的消息不会被记录。服务级别和传输级别消息的默认值为 256K,而格式错误的消息的默认值为 4K。
一个非常基本的配置是
<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>
Run Code Online (Sandbox Code Playgroud)
编辑 :
您使用流媒体吗?对于流式消息,仅记录标头。你无法改变这一点。为了查看正文内容,您唯一的选择就是禁用流式传输。
将绑定配置(服务和客户端)中的TransferMode属性更改为Buffered。