Как правильно задать идентификатор для XML при подписывании запроса?
При попытке подписывания XML выходит ошибка: org.apache.xml.security.utils.resolver.ResourceResolverException: Cannot resolve element with ID 456123
Что я пробовал
body.setIdAttributeNS(WSConstants.WSU_NS, "Id", true);((Element)idAttr.getOwnerElement()).setIdAttributeNode(idAttr,true)
Еще я пробовал много похожих способов, позволяющих привязывать идентификатор к xml, но все безуспешно.
Но, интересно то, что когда я проверяю idAttr.isId() оно возвращает мне TRUE, но ошибка все равно выходит.
Застрял с этой проблемой, подскажите, как я могу решить эту проблему. Заранее благодарю.
прикрепляю куски кода и подписываемого xml:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" SOAP-ENV:mustUnderstand="1">
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
<ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#gost34310-gost34311" />
<ds:Reference URI="#456123">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#gost34311" />
<ds:DigestValue>digValue</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>sigValue
</ds:SignatureValue>
<ds:KeyInfo>
<wsse:SecurityTokenReference>
<wsse:KeyIdentifier EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3">myx509token</wsse:KeyIdentifier>
</wsse:SecurityTokenReference>
</ds:KeyInfo>
</ds:Signature>
</wsse:Security>
</SOAP-ENV:Header>
<SOAP-ENV:Body xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="456123">
some body request
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
и кусок кода:
SOAPBody body = envelope.getBody();
String bodyId = "456123";
body.addAttribute(new QName(WSConstants.WSU_NS, "Id", WSConstants.WSU_PREFIX), bodyId);
body.setIdAttributeNS(WSConstants.WSU_NS, "Id", true);
Attr idAttr = body.getAttributeNode("wsu:Id");
var isIdFlag = idAttr.isId(); *//это возвращает мне TRUE даже без метода setIdAttributeNS*