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


Java SOAPElement.setTextContent方法代码示例

本文整理汇总了Java中javax.xml.soap.SOAPElement.setTextContent方法的典型用法代码示例。如果您正苦于以下问题:Java SOAPElement.setTextContent方法的具体用法?Java SOAPElement.setTextContent怎么用?Java SOAPElement.setTextContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.xml.soap.SOAPElement的用法示例。


在下文中一共展示了SOAPElement.setTextContent方法的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: createProbeXML

import javax.xml.soap.SOAPElement; //导入方法依赖的package包/类
private byte[] createProbeXML() throws SOAPException, IOException {
	MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
	SOAPMessage message = messageFactory.createMessage();
	SOAPPart part = message.getSOAPPart();
	SOAPEnvelope envelope = part.getEnvelope();
	envelope.addNamespaceDeclaration("wsa", "http://schemas.xmlsoap.org/ws/2004/08/addressing");
	envelope.addNamespaceDeclaration("tns", "http://schemas.xmlsoap.org/ws/2005/04/discovery");
	envelope.addNamespaceDeclaration("nns", "http://www.onvif.org/ver10/network/wsdl");
	QName action = envelope.createQName("Action", "wsa");
	QName mid = envelope.createQName("MessageID", "wsa");
	QName to = envelope.createQName("To", "wsa");
	QName probe = envelope.createQName("Probe", "tns");
	QName types = envelope.createQName("Types", "tns");
	QName tramsmitter=envelope.createQName("NetworkVideoTransmitter", "nns");
	SOAPHeader header = envelope.getHeader();
	SOAPElement actionEl = header.addChildElement(action);
	actionEl.setTextContent("http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe");
	SOAPElement messIsEl = header.addChildElement(mid);
	messIsEl.setTextContent("urn:uuid:" + UUID.randomUUID().toString());
	SOAPElement toEl = header.addChildElement(to);
	toEl.setTextContent("urn:schemas-xmlsoap-org:ws:2005:04:discovery");
	SOAPBody body = envelope.getBody();
	SOAPElement probeEl = body.addChildElement(probe);
	SOAPElement typesEl=probeEl.addChildElement(types);
	typesEl.setTextContent("nns:NetworkVideoTransmitter");
	ByteArrayOutputStream out = new ByteArrayOutputStream();
	message.writeTo(out);
	return out.toByteArray();
}
 
开发者ID:D2Edev,项目名称:onvifjava,代码行数:30,代码来源:CameraDiscovery.java


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