当前位置: 首页>>代码示例>>Java>>正文


Java SOAPElement.setAttribute方法代码示例

本文整理汇总了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());
	}
}
 
开发者ID:D2Edev,项目名称:onvifjava,代码行数:36,代码来源:SoapClient.java

示例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);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:MUTube.java


注:本文中的javax.xml.soap.SOAPElement.setAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。