我正在尝试学习WCF手册中的示例并尝试检查HTTP请求/响应。我可以在MS TraceViewer中看到HTTP请求标头,但奇怪的是不是响应标头。 (只有信封)。如果你发现有什么不妥,请告诉我吗?
<configuration>
<system.serviceModel>
<diagnostics>
<messageLogging logEntireMessage="true" logMalformedMessages="true"
logMessagesAtServiceLevel="true"/>
</diagnostics>
<!--other stuff-->
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Off, ActivityTracing">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add initializeData="x.log" type="System.Diagnostics.XmlWriterTraceListener"
name="sdt">
<filter type="" />
</add>
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging" switchValue="Verbose,ActivityTracing">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add name="ServiceModelMessageLoggingListener">
<filter type="" />
</add>
</listeners>
</source>
</sources>
<sharedListeners>
<add initializeData="D:\temp\messages.xml" type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
<filter type="" />
</add>
</sharedListeners>
<trace autoflush="true" />
</system.diagnostics>
</configuration>
请求被正确记录:
<MessageLogTraceRecord>
<HttpRequest xmlns="http://schemas.microsoft.com/2004/06/ServiceModel/Management/MessageTrace">
<Method>POST</Method>
<QueryString></QueryString>
<WebHeaders>
<SOAPAction>"http://www.thatindigogirl.com/samples/2006/06/GigManagerServiceContract/SaveGig"</SOAPAction>
<Connection>Keep-Alive</Connection>
<Content-Length>485</Content-Length>
<Content-Type>text/xml; charset=utf-8</Content-Type>
<Expect>100-continue</Expect>
<Host>localhost:8000</Host>
</WebHeaders>
</HttpRequest>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<To s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://localhost:8000/GigManagerService</To>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://www.thatindigogirl.com/samples/2006/06/GigManagerServiceContract/SaveGig</Action>
</s:Header>
<s:Body>
<SaveGig xmlns="http://www.thatindigogirl.com/samples/2006/06">
<item xmlns:a="wcf_expts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:DateEnd>2009-11-01T05:30:00</a:DateEnd>
<a:DateStart>2009-10-31T22:30:00</a:DateStart>
<a:Description>some desc</a:Description>
<a:Id>0</a:Id>
<a:Place i:nil="true"></a:Place>
<a:Title>some boring event</a:Title>
<a:Url>http://askfdj.com</a:Url>
</item>
</SaveGig>
</s:Body>
</s:Envelope>
</MessageLogTraceRecord>
我在跟踪查看器中看到的响应(为什么没有标题,http响应?)
<MessageLogTraceRecord>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://www.thatindigogirl.com/samples/2006/06/GigManagerServiceContract/SaveGigResponse</Action>
</s:Header>
<s:Body>
<SaveGigResponse xmlns="http://www.thatindigogirl.com/samples/2006/06"></SaveGigResponse>
</s:Body>
</s:Envelope>
</MessageLogTraceRecord>
答案 0 :(得分:2)
你在响应方面做流媒体吗?这可以解释它 - 当你使用流媒体时,只会记录标题(而不是流数据)。
马克
答案 1 :(得分:1)
如果消息是流式传输的,您会在跟踪的Body标签中看到“... stream ...”(我写了一个post on that。
对于HttpRequest的响应,是否有其他标头而不是SOAP标头?我的意思是你似乎寻找的是HttpRequest标头,但响应不是HttpRequest。我不确定,所以我可能错了:)