请告知我们如何在soap request xml中生成动态wsu:Id。
<wsu:Timestamp wsu:Id="TS-C68ABF4EC1E628F5B5143638245038886955">
<wsu:Created>2015-07-08T19:07:30.388Z</wsu:Created>
<wsu:Expires>2015-07-08T19:12:30.388Z</wsu:Expires>
</wsu:Timestamp>
Java代码:
私有元素addTimestamp(Element wsSecurityHeaderElement)引发SOAPException,DatatypeConfigurationException {/ 如果(false == this.addTimestamp){返回null;} /文档document = wsSecurityHeaderElement.getOwnerDocument();元素timestampElement = document.createElementNS(WSU_NAMESPACE,“ wsu:Timestamp”);timestampElement.setAttributeNS(WSU_NAMESPACE,“ wsu:Id”,“ TS”);//需要删除硬编码的ts属性idAttr = timestampElement.getAttributeNodeNS(WSU_NAMESPACE,“ Id”);timestampElement.setIdAttributeNode(idAttr,true);元素createdElement = document.createElementNS(WSU_NAMESPACE,“ wsu:Created”);DatatypeFactory datatypeFactory = DatatypeFactory.newInstance();GregorianCalendar gregorianCalendar =新的GregorianCalendar();现在的日期=新的Date();gregorianCalendar.setTime(now);gregorianCalendar.setTimeZone(TimeZone.getTimeZone(“ UTC”));XMLGregorianCalendar xmlGregorianCalendar = datatypeFactory.newXMLGregorianCalendar(gregorianCalendar);createdElement.setTextContent(xmlGregorianCalendar.toXMLFormat());timestampElement.appendChild(createdElement); Element expiresElement = document.createElementNS(WSU_NAMESPACE,
"wsu:Expires");
Date expiresDate = new Date(now.getTime() + 1000 * 60 * 5);
gregorianCalendar.setTime(expiresDate);
xmlGregorianCalendar = datatypeFactory
.newXMLGregorianCalendar(gregorianCalendar);
expiresElement.setTextContent(xmlGregorianCalendar.toXMLFormat());
timestampElement.appendChild(expiresElement);
wsSecurityHeaderElement.appendChild(timestampElement);
return timestampElement;
} </code>
您是否添加了wsu:Id =“ TS-C68ABF4EC1E628F5B5143638245038886955”?什么是C68ABF4EC1E628F5B5143638245038886955部分?