當前位置: 首頁>>代碼示例>>Java>>正文


Java SOAPMessage.getSOAPHeader方法代碼示例

本文整理匯總了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());
	}
}
 
開發者ID:D2Edev,項目名稱:onvifjava,代碼行數:36,代碼來源:SoapClient.java

示例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);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:23,代碼來源:StreamHeader.java

示例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);
        }
    }
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:27,代碼來源:EPRHeader.java

示例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);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:17,代碼來源:OutboundReferenceParameterHeader.java

示例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);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:23,代碼來源:StreamHeader.java

示例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);
        }
    }
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:27,代碼來源:EPRHeader.java

示例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);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:11,代碼來源:OutboundStreamHeader.java

示例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);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:9,代碼來源:FaultDetailHeader.java

示例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);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:11,代碼來源:StringHeader.java

示例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);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:13,代碼來源:ProblemActionHeader.java

示例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);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:11,代碼來源:JAXBHeader.java

示例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);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:12,代碼來源:RelatesToHeader.java

示例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);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:8,代碼來源:DOMHeader.java


注:本文中的javax.xml.soap.SOAPMessage.getSOAPHeader方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。