SOAPElementに新しいノードを追加する際に、不要な属性xmlns = ""が追加されています。 どうすれば解決できますか?JAVAX:不要な属性
...
SOAPFactory factory = SOAPFactory.newInstance();
SOAPElement securityElem = factory.createElement("Security", null, "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
SOAPElement tokenElem = factory.createElement("UsernameToken");
...
securityElem.addChildElement(tokenElem);
結果:
<Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<UsernameToken xmlns=""/> </Security>
しかし、私はこの必要があります:あなたは要素が親要素と同じ名前空間になりたい場合は、明示的にそれを作成する必要があります
<Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<UsernameToken/> </Security>
結果: –
が必要です。 –