本文整理汇总了Java中javax.xml.soap.SOAPElement.setAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java SOAPElement.setAttribute方法的具体用法?Java SOAPElement.setAttribute怎么用?Java SOAPElement.setAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.soap.SOAPElement
的用法示例。
在下文中一共展示了SOAPElement.setAttribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addSoapHeader
import javax.xml.soap.SOAPElement; //导入方法依赖的package包/类
protected void addSoapHeader(SOAPMessage soapMessage) throws SOAPException, NoSuchAlgorithmException {
onvifDevice.createNonce();
String encrypedPassword = onvifDevice.getEncryptedPassword();
if (encrypedPassword != null && onvifDevice.getUsername() != null) {
SOAPPart sp = soapMessage.getSOAPPart();
SOAPEnvelope se = sp.getEnvelope();
SOAPHeader header = soapMessage.getSOAPHeader();
se.addNamespaceDeclaration("wsse",
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
se.addNamespaceDeclaration("wsu",
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
SOAPElement securityElem = header.addChildElement("Security", "wsse");
// securityElem.setAttribute("SOAP-ENV:mustUnderstand", "1");
SOAPElement usernameTokenElem = securityElem.addChildElement("UsernameToken", "wsse");
SOAPElement usernameElem = usernameTokenElem.addChildElement("Username", "wsse");
usernameElem.setTextContent(onvifDevice.getUsername());
SOAPElement passwordElem = usernameTokenElem.addChildElement("Password", "wsse");
passwordElem.setAttribute("Type",
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest");
passwordElem.setTextContent(encrypedPassword);
SOAPElement nonceElem = usernameTokenElem.addChildElement("Nonce", "wsse");
nonceElem.setAttribute("EncodingType",
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary");
nonceElem.setTextContent(onvifDevice.getEncryptedNonce());
SOAPElement createdElem = usernameTokenElem.addChildElement("Created", "wsu");
createdElem.setTextContent(onvifDevice.getLastUTCTime());
}
}
示例2: addHeader
import javax.xml.soap.SOAPElement; //导入方法依赖的package包/类
private static void addHeader(Message m, Set<QName> notUnderstoodHeaders) throws SOAPException {
for (QName qname : notUnderstoodHeaders) {
SOAPElement soapEl = SOAP_12.getSOAPFactory().createElement(MU_HEADER_DETAIL);
soapEl.addNamespaceDeclaration("abc", qname.getNamespaceURI());
soapEl.setAttribute("qname", "abc:" + qname.getLocalPart());
Header header = new DOMHeader<Element>(soapEl);
m.getHeaders().add(header);
}
}