0
我有一个web服务(.net),它将获取(AfterReceiveRequest)传入的消息,然后检查标头的客户端标识。如何解析不同的XML文档?
当记录与数据内置的日志我得到喜欢这个电子文档:
<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>
现在我需要将其转换为我能在forexample的soapUI发送常规XML消息。
当soupUI增加一个项目中,我得到以下
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body/>
</soapenv:Envelope>
我需要在这里添加标题信息,但不知道如何做到这一点的样子。我试图将日志中的部分复制到XML消息中,但这没有任何作用。
- 如何将日志标题转换为SoupUI标头?
- 这为什么和this这样的普通XML不一样?什么soapenv:信封从哪里来?为什么日志中的原始xml不同?
这究竟是不是“正规的XML”?您是否使用名称空间前缀感到困惑? –