【发布时间】:2018-01-17 14:12:05
【问题描述】:
请考虑作为对 SOAP 调用的响应而生成的这两个等效 xml 文档。
文件一:
<?xml version="1.0" encoding="utf-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header>
<ns2:ServerVersionInfo xmlns:ns3="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/types" MajorVersion="15" MinorVersion="1" MajorBuildNumber="845" MinorBuildNumber="34"/>
</S:Header>
<S:Body>
<ns3:GetUserAvailabilityResponse xmlns:ns3="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/types">
<ns3:FreeBusyResponseArray>
<ns3:FreeBusyResponse>
<ns3:ResponseMessage ResponseClass="Success">
<ns3:ResponseCode>NoError</ns3:ResponseCode>
</ns3:ResponseMessage>
<ns3:FreeBusyView>
<ns2:FreeBusyViewType>MergedOnly</ns2:FreeBusyViewType>
<ns2:MergedFreeBusy>0000</ns2:MergedFreeBusy>
</ns3:FreeBusyView>
</ns3:FreeBusyResponse>
</ns3:FreeBusyResponseArray>
</ns3:GetUserAvailabilityResponse>
</S:Body>
</S:Envelope>
文档二:
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" MajorVersion="15" MinorVersion="1" MajorBuildNumber="845" MinorBuildNumber="34"/>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<GetUserAvailabilityResponse xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
<FreeBusyResponseArray>
<FreeBusyResponse>
<ResponseMessage ResponseClass="Success">
<ResponseCode>NoError</ResponseCode>
</ResponseMessage>
<FreeBusyView>
<FreeBusyViewType xmlns="http://schemas.microsoft.com/exchange/services/2006/types">MergedOnly</FreeBusyViewType>
<MergedFreeBusy xmlns="http://schemas.microsoft.com/exchange/services/2006/types">0000</MergedFreeBusy>
</FreeBusyView>
</FreeBusyResponse>
</FreeBusyResponseArray>
</GetUserAvailabilityResponse>
</s:Body>
</s:Envelope>
如果我错了,请纠正我,但除了 xml 命名空间声明样式之外,这些 DOM 在语义上看起来很相似。我想从文档一的样式和文档二的样式调整我的 java 应用程序的 jax-ws 输出。
如有必要,我可以使用 javax.xml.transform.Transformer 重新处理 DOM。
【问题讨论】: