如何解释不同的XML文档?

时间:2011-11-07 10:20:49

标签: xml logging

我有一个webservice(.net),它将获取(AfterReceiveRequest)传入的消息,然后检查标头是否有客户端标识。

使用内置日志记录数据时,我得到如下文档:

<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
<System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
<EventID>0</EventID>
<Type>3</Type>
<SubType Name="Information">0</SubType>
<Level>8</Level>
<TimeCreated SystemTime="2011-11-03T14:58:51.4037710Z" />
<Source Name="System.ServiceModel.MessageLogging" />
<Correlation ActivityID="{cca863d4-c100-4890-bdee-b2822b8c3c51}" />
<Execution ProcessName="w3wp" ProcessID="1668" ThreadID="11" />
<Channel />
<Computer>MYComputer</Computer>
</System>
<ApplicationData>
<TraceData>
<DataItem>
<MessageLogTraceRecord Time="2011-11-03T15:58:51.4027703+01:00" Source="ServiceLevelReceiveRequest" Type="System.ServiceModel.Channels.BufferedMessage" xmlns="http://schemas.microsoft.com/2004/06/ServiceModel/Management/MessageTrace">
<HttpRequest>
<Method>POST</Method>
<QueryString></QueryString>
<WebHeaders>
<Connection>Keep-Alive</Connection>
<Content-Length>411</Content-Length>
<Content-Type>text/xml; charset=utf-8</Content-Type>
<Accept-Encoding>gzip, deflate</Accept-Encoding>
<Expect>100-continue</Expect>
<Host>localhost</Host>
<VsDebuggerCausalityData>uIDPo+iMUXXYvrRMsLtwZXbu2nsAAAAA9T4PAazUO0qPWWgM4JKb9L8HlsY5ehRBsbM2cjOrd2YACQAA</VsDebuggerCausalityData>
<SOAPAction>"GetVersion"</SOAPAction>
</WebHeaders>
</HttpRequest>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<SecurityToken xmlns="ns" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Password xmlns="http://schemas.datacontract.org/2004/07/MyApp.DataContracts.External">MyPassword</Password>
<UserName xmlns="http://schemas.datacontract.org/2004/07/ MyApp.DataContracts.External">MyUserName</UserName>
</SecurityToken>
<To s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://MyApp.local/Test/Integration.svc</To>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">GetVersion</Action>
</s:Header>
</s:Envelope>
</MessageLogTraceRecord>
</DataItem>
</TraceData>
</ApplicationData>
</E2ETraceEvent>

现在我需要将其转换为我可以在例如soapUI中发送的常规XML消息。

在soupUI中添加项目时,我得到以下内容

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header/>
   <soapenv:Body/>
</soapenv:Envelope>

我需要在这里添加标题信息,但不确定这是怎么回事。我试图将日志中的部分复制到XML消息中,但这没有任何作用。

  1. 如何将日志标头转换为SoupUI标头?
  2. 为什么这与常规XML如this不一样? soapenv:信封来自哪里?为什么日志中的原始xml不同?

1 个答案:

答案 0 :(得分:0)

通过实验,我得到了以下内容:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header>
     <SecurityToken xmlns="ns" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
       <Password xmlns="http://schemas.datacontract.org/2004/07/MyApp.DataContracts.External">MyUser</Password>
       <UserName xmlns="http://schemas.datacontract.org/2004/07/MyApp.DataContracts.External">MyPassword</UserName>
     </SecurityToken>
   </soapenv:Header>
   <soapenv:Body/>
</soapenv:Envelope>

这很棒!

但是,我不清楚为什么日志有汤汁有?