本文整理汇总了Java中javax.xml.soap.SOAPMessage.getSOAPHeader方法的典型用法代码示例。如果您正苦于以下问题:Java SOAPMessage.getSOAPHeader方法的具体用法?Java SOAPMessage.getSOAPHeader怎么用?Java SOAPMessage.getSOAPHeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.soap.SOAPMessage
的用法示例。
在下文中一共展示了SOAPMessage.getSOAPHeader方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addSoapHeader
import javax.xml.soap.SOAPMessage; //导入方法依赖的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: writeTo
import javax.xml.soap.SOAPMessage; //导入方法依赖的package包/类
public void writeTo(SOAPMessage saaj) throws SOAPException {
try {
// TODO what about in-scope namespaces
// Not very efficient consider implementing a stream buffer
// processor that produces a DOM node from the buffer.
TransformerFactory tf = XmlUtil.newTransformerFactory();
Transformer t = tf.newTransformer();
XMLStreamBufferSource source = new XMLStreamBufferSource(_mark);
DOMResult result = new DOMResult();
t.transform(source, result);
Node d = result.getNode();
if(d.getNodeType() == Node.DOCUMENT_NODE)
d = d.getFirstChild();
SOAPHeader header = saaj.getSOAPHeader();
if(header == null)
header = saaj.getSOAPPart().getEnvelope().addHeader();
Node node = header.getOwnerDocument().importNode(d, true);
header.appendChild(node);
} catch (Exception e) {
throw new SOAPException(e);
}
}
示例3: writeTo
import javax.xml.soap.SOAPMessage; //导入方法依赖的package包/类
public void writeTo(SOAPMessage saaj) throws SOAPException {
try {
// TODO what about in-scope namespaces
// Not very efficient consider implementing a stream buffer
// processor that produces a DOM node from the buffer.
Transformer t = XmlUtil.newTransformer();
SOAPHeader header = saaj.getSOAPHeader();
if (header == null)
header = saaj.getSOAPPart().getEnvelope().addHeader();
// TODO workaround for oracle xdk bug 16555545, when this bug is fixed the line below can be
// uncommented and all lines below, except the catch block, can be removed.
// t.transform(epr.asSource(localName), new DOMResult(header));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
XMLStreamWriter w = XMLOutputFactory.newFactory().createXMLStreamWriter(baos);
epr.writeTo(localName, w);
w.flush();
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
DocumentBuilderFactory fac = DocumentBuilderFactory.newInstance();
fac.setNamespaceAware(true);
Node eprNode = fac.newDocumentBuilder().parse(bais).getDocumentElement();
Node eprNodeToAdd = header.getOwnerDocument().importNode(eprNode, true);
header.appendChild(eprNodeToAdd);
} catch (Exception e) {
throw new SOAPException(e);
}
}
示例4: writeTo
import javax.xml.soap.SOAPMessage; //导入方法依赖的package包/类
@Override
public void writeTo(SOAPMessage saaj) throws SOAPException {
//TODO: SAAJ returns null instead of throwing SOAPException,
// when there is no SOAPHeader in the message,
// which leads to NPE.
try {
SOAPHeader header = saaj.getSOAPHeader();
if (header == null) {
header = saaj.getSOAPPart().getEnvelope().addHeader();
}
Element node = (Element)infoset.writeTo(header);
node.setAttributeNS(AddressingVersion.W3C.nsUri,AddressingVersion.W3C.getPrefix()+":"+IS_REFERENCE_PARAMETER,TRUE_VALUE);
} catch (XMLStreamBufferException e) {
throw new SOAPException(e);
}
}
示例5: writeTo
import javax.xml.soap.SOAPMessage; //导入方法依赖的package包/类
public void writeTo(SOAPMessage saaj) throws SOAPException {
try {
// TODO what about in-scope namespaces
// Not very efficient consider implementing a stream buffer
// processor that produces a DOM node from the buffer.
TransformerFactory tf = XmlUtil.newTransformerFactory(true);
Transformer t = tf.newTransformer();
XMLStreamBufferSource source = new XMLStreamBufferSource(_mark);
DOMResult result = new DOMResult();
t.transform(source, result);
Node d = result.getNode();
if(d.getNodeType() == Node.DOCUMENT_NODE)
d = d.getFirstChild();
SOAPHeader header = saaj.getSOAPHeader();
if(header == null)
header = saaj.getSOAPPart().getEnvelope().addHeader();
Node node = header.getOwnerDocument().importNode(d, true);
header.appendChild(node);
} catch (Exception e) {
throw new SOAPException(e);
}
}
示例6: writeTo
import javax.xml.soap.SOAPMessage; //导入方法依赖的package包/类
public void writeTo(SOAPMessage saaj) throws SOAPException {
try {
// TODO what about in-scope namespaces
// Not very efficient consider implementing a stream buffer
// processor that produces a DOM node from the buffer.
Transformer t = XmlUtil.newTransformer();
SOAPHeader header = saaj.getSOAPHeader();
if (header == null)
header = saaj.getSOAPPart().getEnvelope().addHeader();
// TODO workaround for oracle xdk bug 16555545, when this bug is fixed the line below can be
// uncommented and all lines below, except the catch block, can be removed.
// t.transform(epr.asSource(localName), new DOMResult(header));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
XMLStreamWriter w = XMLOutputFactory.newFactory().createXMLStreamWriter(baos);
epr.writeTo(localName, w);
w.flush();
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
DocumentBuilderFactory fac = XmlUtil.newDocumentBuilderFactory(false);
fac.setNamespaceAware(true);
Node eprNode = fac.newDocumentBuilder().parse(bais).getDocumentElement();
Node eprNodeToAdd = header.getOwnerDocument().importNode(eprNode, true);
header.appendChild(eprNodeToAdd);
} catch (Exception e) {
throw new SOAPException(e);
}
}
示例7: writeTo
import javax.xml.soap.SOAPMessage; //导入方法依赖的package包/类
public void writeTo(SOAPMessage saaj) throws SOAPException {
try {
SOAPHeader header = saaj.getSOAPHeader();
if (header == null)
header = saaj.getSOAPPart().getEnvelope().addHeader();
infoset.writeTo(header);
} catch (XMLStreamBufferException e) {
throw new SOAPException(e);
}
}
示例8: writeTo
import javax.xml.soap.SOAPMessage; //导入方法依赖的package包/类
public void writeTo(SOAPMessage saaj) throws SOAPException {
SOAPHeader header = saaj.getSOAPHeader();
if (header == null)
header = saaj.getSOAPPart().getEnvelope().addHeader();
SOAPHeaderElement she = header.addHeaderElement(av.faultDetailTag);
she = header.addHeaderElement(new QName(av.nsUri, wrapper));
she.addTextNode(problemValue);
}
示例9: writeTo
import javax.xml.soap.SOAPMessage; //导入方法依赖的package包/类
public void writeTo(SOAPMessage saaj) throws SOAPException {
SOAPHeader header = saaj.getSOAPHeader();
if(header == null)
header = saaj.getSOAPPart().getEnvelope().addHeader();
SOAPHeaderElement she = header.addHeaderElement(name);
if(mustUnderstand) {
she.setMustUnderstand(true);
}
she.addTextNode(value);
}
示例10: writeTo
import javax.xml.soap.SOAPMessage; //导入方法依赖的package包/类
public void writeTo(SOAPMessage saaj) throws SOAPException {
SOAPHeader header = saaj.getSOAPHeader();
if(header == null)
header = saaj.getSOAPPart().getEnvelope().addHeader();
SOAPHeaderElement she = header.addHeaderElement(new QName(getNamespaceURI(), getLocalPart()));
she.addChildElement(actionLocalName);
she.addTextNode(action);
if (soapAction != null) {
she.addChildElement(soapActionLocalName);
she.addTextNode(soapAction);
}
}
示例11: writeTo
import javax.xml.soap.SOAPMessage; //导入方法依赖的package包/类
public void writeTo(SOAPMessage saaj) throws SOAPException {
try {
SOAPHeader header = saaj.getSOAPHeader();
if (header == null)
header = saaj.getSOAPPart().getEnvelope().addHeader();
bridge.marshal(jaxbObject,header);
} catch (JAXBException e) {
throw new SOAPException(e);
}
}
示例12: writeTo
import javax.xml.soap.SOAPMessage; //导入方法依赖的package包/类
@Override
public void writeTo(SOAPMessage saaj) throws SOAPException {
SOAPHeader header = saaj.getSOAPHeader();
if (header == null)
header = saaj.getSOAPPart().getEnvelope().addHeader();
SOAPHeaderElement she = header.addHeaderElement(name);
if (type != null)
she.addAttribute(typeAttributeName, type);
she.addTextNode(value);
}
示例13: writeTo
import javax.xml.soap.SOAPMessage; //导入方法依赖的package包/类
public void writeTo(SOAPMessage saaj) throws SOAPException {
SOAPHeader header = saaj.getSOAPHeader();
if(header == null)
header = saaj.getSOAPPart().getEnvelope().addHeader();
Node clone = header.getOwnerDocument().importNode(node,true);
header.appendChild(clone);
}