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


Java SOAPHeader.appendChild方法代碼示例

本文整理匯總了Java中javax.xml.soap.SOAPHeader.appendChild方法的典型用法代碼示例。如果您正苦於以下問題:Java SOAPHeader.appendChild方法的具體用法?Java SOAPHeader.appendChild怎麽用?Java SOAPHeader.appendChild使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.xml.soap.SOAPHeader的用法示例。


在下文中一共展示了SOAPHeader.appendChild方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: writeTo

import javax.xml.soap.SOAPHeader; //導入方法依賴的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

示例2: writeTo

import javax.xml.soap.SOAPHeader; //導入方法依賴的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

示例3: writeTo

import javax.xml.soap.SOAPHeader; //導入方法依賴的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

示例4: writeTo

import javax.xml.soap.SOAPHeader; //導入方法依賴的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

示例5: copyToSOAPHeader

import javax.xml.soap.SOAPHeader; //導入方法依賴的package包/類
private void copyToSOAPHeader(SOAPHeader soapHeader, Property property) throws IOException, SOAPException {
    if ((property != null) && (matches(property.getName(), getIncludeRegexes(), new ArrayList<Pattern>()))) {
        String v = property.getValue().toString();
        QName qname = new QName(HEADER_NAMESPACE_PROPAGATION, property.getName());
        if (SOAPHeadersType.XML.equals(_soapHeadersType)) {
            try {
                Element xmlElement = new ElementPuller().pull(new StringReader(v));
                Node xmlNode = soapHeader.getOwnerDocument().importNode(xmlElement, true);
                soapHeader.appendChild(xmlNode);
            } catch (Throwable t) {
                soapHeader.addChildElement(qname).setValue(v);
            }
        } else {
            soapHeader.addChildElement(qname).setValue(v);
        }
    }
}
 
開發者ID:jboss-switchyard,項目名稱:switchyard,代碼行數:18,代碼來源:SOAPContextMapper.java

示例6: writeTo

import javax.xml.soap.SOAPHeader; //導入方法依賴的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 = TransformerFactory.newInstance();
        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:alexkasko,項目名稱:openjdk-icedtea7,代碼行數:23,代碼來源:StreamHeader.java

示例7: writeTo

import javax.xml.soap.SOAPHeader; //導入方法依賴的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

示例8: getSecurityElement

import javax.xml.soap.SOAPHeader; //導入方法依賴的package包/類
/**
 * Finds the Security element from the header. If not found then creates one
 * and returns the same
 *
 * @param header
 * @return
 */
public static Node getSecurityElement(SOAPHeader header) {
    NodeList targetElement = header.getElementsByTagNameNS(Constants.WSS_NS,
        Constants.SECURITY_ELEMENT_NAME);
    if (targetElement == null || targetElement.getLength() == 0) {
        JAXBElement<SecurityHeaderType> value = wsseObjFactory
            .createSecurity(wsseObjFactory.createSecurityHeaderType());
        Node headerNode = marshallJaxbElement(value).getDocumentElement();
        return header.appendChild(header.getOwnerDocument().importNode(
            headerNode, true));
    } else if (targetElement.getLength() > 1) {
        throw new RuntimeException(Constants.ERR_INSERTING_SECURITY_HEADER);
    }
    return targetElement.item(0);
}
 
開發者ID:vmware,項目名稱:vsphere-automation-sdk-java,代碼行數:22,代碼來源:WssHelper.java

示例9: updateSoapNsiHeaders

import javax.xml.soap.SOAPHeader; //導入方法依賴的package包/類
private void updateSoapNsiHeaders(SOAPHeader soapHeader, CommonHeaderType headers) {
  for (Iterator<?> it = soapHeader.getChildElements(COMMON_HEADER_CONVERTER.getXmlRootElementName()); it.hasNext();) {
    Node child = (Node) it.next();
    if (LOGGER.isTraceEnabled()) {
      LOGGER.trace("Removing headers " + child);
    }
    soapHeader.removeChild(child);
  }
  if (LOGGER.isTraceEnabled()) {
    LOGGER.trace("Appending headers " + headers);
  }
  Element headersElement = COMMON_HEADER_CONVERTER.toDomElement(headers);
  soapHeader.appendChild(soapHeader.getOwnerDocument().importNode(headersElement, true));
}
 
開發者ID:BandwidthOnDemand,項目名稱:bandwidth-on-demand,代碼行數:15,代碼來源:UpdateNsiHeadersForAckHandler.java

示例10: createSOAPMessage

import javax.xml.soap.SOAPHeader; //導入方法依賴的package包/類
public static final SOAPMessage createSOAPMessage(String soapProtocol, String ebmsMessage) throws Exception{
    MessageFactory messageFactory = MessageFactory.newInstance(soapProtocol);
    SOAPMessage soapMessage = messageFactory.createMessage();
    SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope();
    soapMessage.getSOAPPart().addMimeHeader("Content-ID", "<[email protected]>");
    SOAPHeader soapHeader = soapEnvelope.getHeader();

    Element ebms = toXML(ebmsMessage).getDocumentElement();
    Node node = soapEnvelope.getOwnerDocument().importNode(ebms,true);
    soapHeader.appendChild(node);
    soapMessage.saveChanges();

    return soapMessage;
}
 
開發者ID:jentrata,項目名稱:jentrata,代碼行數:15,代碼來源:EbmsUtils.java

示例11: appendSecurityHeader

import javax.xml.soap.SOAPHeader; //導入方法依賴的package包/類
private void appendSecurityHeader(SOAPHeader soapHeader, Element securityElement) {
	soapHeader.removeChild(securityElement);
	soapHeader.appendChild(securityElement);
}
 
開發者ID:e-Contract,項目名稱:dssp,代碼行數:5,代碼來源:WSSecuritySOAPHandler.java

示例12: testAppendChild

import javax.xml.soap.SOAPHeader; //導入方法依賴的package包/類
@Validated @Test
public void testAppendChild() throws Exception {
    MessageFactory fact = MessageFactory.newInstance();
    SOAPMessage message = fact.createMessage();
    SOAPHeader soapHeader = message.getSOAPHeader();
    
    assertEquals(0, soapHeader.getChildNodes().getLength());
    assertFalse(soapHeader.getChildElements().hasNext());
    
    Document doc = soapHeader.getOwnerDocument();        
    String namespace = "http://example.com";
    String localName = "GetLastTradePrice";
    Element getLastTradePrice = doc.createElementNS(namespace, localName);        
    Element symbol = doc.createElement("symbol");
    symbol.setAttribute("foo", "bar");
    getLastTradePrice.appendChild(symbol);
    org.w3c.dom.Text def = doc.createTextNode("DEF");
    symbol.appendChild(def);
                    
    soapHeader.appendChild(getLastTradePrice);
            
    assertEquals(1, soapHeader.getChildNodes().getLength());
    Iterator iter = soapHeader.getChildElements();
    assertTrue(iter.hasNext()); 
    Object obj = iter.next();
    // must be SOAPHeaderElement
    assertTrue(obj instanceof SOAPHeaderElement);  
    SOAPElement soapElement = (SOAPElement)obj;
    assertEquals(namespace, soapElement.getNamespaceURI());
    assertEquals(localName, soapElement.getLocalName());
    
    iter = soapElement.getChildElements();
    assertTrue(iter.hasNext()); 
    obj = iter.next();
    assertTrue(obj instanceof SOAPElement);  
    soapElement = (SOAPElement)obj;
    assertEquals(null, soapElement.getNamespaceURI());
    assertEquals("symbol", soapElement.getLocalName());
    assertFalse(iter.hasNext());
    
    iter = soapElement.getChildElements();
    assertTrue(iter.hasNext()); 
    obj = iter.next();
    assertTrue(obj instanceof Text);  
    Text text = (Text)obj;
    assertEquals("DEF", text.getData());
    assertFalse(iter.hasNext());   
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:49,代碼來源:SOAPHeaderTest.java


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