本文整理汇总了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());
}
}
示例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();
}