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


Java SOAPHeader.getChildElements方法代碼示例

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


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

示例1: parseXteeHeader

import javax.xml.soap.SOAPHeader; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private XTeeHeader parseXteeHeader(SOAPMessage paringMessage) throws SOAPException {
  XTeeHeader pais = new XTeeHeader();
  if (paringMessage.getSOAPHeader() == null) {
    return pais;
  }

  SOAPHeader header = paringMessage.getSOAPHeader();
  for (Iterator<Node> headerElemendid = header.getChildElements(); headerElemendid.hasNext();) {
    Node headerElement = headerElemendid.next();
    if (!SOAPUtil.isTextNode(headerElement) && headerElement.getFirstChild() != null) {
      String localName = headerElement.getLocalName();
      String value = headerElement.getFirstChild().getNodeValue();
      pais.addElement(new QName(headerElement.getNamespaceURI(), localName), value);
    }
  }
  return pais;
}
 
開發者ID:nortal,項目名稱:j-road,代碼行數:19,代碼來源:AbstractXTeeBaseEndpoint.java

示例2: getSecurityHeader

import javax.xml.soap.SOAPHeader; //導入方法依賴的package包/類
private SOAPHeaderElement getSecurityHeader(SOAPEnvelope envelope) throws SOAPException {
    if (envelope != null) {
        SOAPHeader header = envelope.getHeader();
        if (header != null) {
            Iterator<?> iter = header.getChildElements(WSSE_QNAME);
            if (iter.hasNext()) {
                return (SOAPHeaderElement)iter.next();
            }
            iter = header.getChildElements(WSSE_2_QNAME);
            if (iter.hasNext()) {
                return (SOAPHeaderElement)iter.next();
            }
            iter = header.getChildElements(WSSE_11_QNAME);
            if (iter.hasNext()) {
                return (SOAPHeaderElement)iter.next();
            }
        }
    }
    return null;
}
 
開發者ID:jboss-switchyard,項目名稱:switchyard,代碼行數:21,代碼來源:SOAPMessageCredentialExtractor.java

示例3: assertAuthenticationHeaderEquals

import javax.xml.soap.SOAPHeader; //導入方法依賴的package包/類
private void assertAuthenticationHeaderEquals(String authenticationToken,
    SOAPHeader header) {
  Iterator<?> headerElements = header.getChildElements(
      AuthenticationHandler.authenticationHeaderName);
  assertTrue(headerElements.hasNext());
  SOAPHeaderElement headerElement =
      (SOAPHeaderElement) headerElements.next();
  Iterator<?> childElements = headerElement.getChildElements(
      AuthenticationHandler.authenticationTokenName);
  assertTrue(childElements.hasNext());
  SOAPElement child = (SOAPElement) childElements.next();
  assertEquals(authenticationToken,
      child.getFirstChild().getNodeValue());
}
 
開發者ID:googlegsa,項目名稱:opentext,代碼行數:15,代碼來源:AuthenticationHandlerTest.java

示例4: testAddSource

import javax.xml.soap.SOAPHeader; //導入方法依賴的package包/類
@Validated @Test
public void testAddSource() throws Exception {
    /*
    FileReader testFile = new FileReader(new File(System.getProperty("basedir",".")+"/test-resources" + File.separator + "soap-part.xml"));
    StAXOMBuilder stAXOMBuilder =
            OMXMLBuilderFactory.createStAXOMBuilder(
                    OMAbstractFactory.getSOAP11Factory(),
                    XMLInputFactory.newInstance().createXMLStreamReader(
                            testFile));
    */

    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    DocumentBuilder builder = dbf.newDocumentBuilder();
    Document document = builder.parse(TestUtils.getTestFileURI("soap-part.xml"));
    DOMSource domSource = new DOMSource(document);

    SOAPMessage message = MessageFactory.newInstance().createMessage();

    // Get the SOAP part and set its content to domSource
    SOAPPart soapPart = message.getSOAPPart();
    soapPart.setContent(domSource);
    message.saveChanges();

    SOAPHeader header = message.getSOAPHeader();
    if (header != null) {
        Iterator iter1 = header.getChildElements();
        getContents(iter1, "");
    }

    SOAPBody body = message.getSOAPBody();
    Iterator iter2 = body.getChildElements();
    getContents(iter2, "");
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:35,代碼來源:SOAPPartTest.java

示例5: renderTpicHeaderToSoapMessage

import javax.xml.soap.SOAPHeader; //導入方法依賴的package包/類
@Test
public void renderTpicHeaderToSoapMessage() throws SOAPException {
	final Map<String, String> context = Collections.singletonMap("FOO", "BAR");
	final SOAPHeader soapHeader = soapMessage.getSOAPHeader();

	unit.renderSoapHeader(context, soapHeader);
	final Iterator soapHeaders = soapHeader.getChildElements(TraceeConstants.SOAP_HEADER_QNAME);

	final Element tpicHeader = (Element) soapHeaders.next();
	assertThat(tpicHeader.getLocalName(), is(TraceeConstants.TPIC_HEADER));
	assertThat(tpicHeader.getNamespaceURI(), is(TraceeConstants.SOAP_HEADER_NAMESPACE));
	assertThat(tpicHeader.getFirstChild().getLocalName(), is("entry"));
	assertThat(tpicHeader.getFirstChild().getAttributes().getNamedItem("key").getNodeValue(), is("FOO"));
	assertThat(tpicHeader.getFirstChild().getFirstChild().getNodeValue(), is("BAR"));
}
 
開發者ID:tracee,項目名稱:tracee,代碼行數:16,代碼來源:SoapHeaderTransportTest.java

示例6: 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

示例7: testAddRemoveAsSOAPMessage

import javax.xml.soap.SOAPHeader; //導入方法依賴的package包/類
public void testAddRemoveAsSOAPMessage() throws Exception {

		MessageContext messageContext = getMessageContext();
		
		SOAPHeadersAdapter.install(messageContext);
		
    	SOAPFactory sf = SOAPFactory.newInstance();
    	
    	// QName used here should match the key for the list set on the requestCtx
    	SOAPElement e1 = sf.createElement(ACOH1_HEADER_QNAME);
    	e1.addTextNode(CONTENT_STRING1);
    	String acoh1 = e1.toString();
    	
    	// QName used here should match the key for the list set on the requestCtx
    	SOAPElement e2 = sf.createElement(ACOH1_HEADER_QNAME);
    	e2.addTextNode(CONTENT_STRING2);
    	String acoh2 = e2.toString();

        List<String> acoh1ContentList = new ArrayList<String>();
        acoh1ContentList.add(acoh1);
        acoh1ContentList.add(acoh2);
        
        SOAPHeadersAdapter adapter = (SOAPHeadersAdapter)messageContext.getProperty(Constants.JAXWS_OUTBOUND_SOAP_HEADERS);
        
        adapter.put(ACOH1_HEADER_QNAME, acoh1ContentList);
        
        // get message object and convert to SOAPMessage
        SOAPMessage soapMessage = messageContext.getMessage().getAsSOAPMessage();
        
        // confirm headers are there
        SOAPHeader soapHeader = soapMessage.getSOAPHeader();
        Iterator<SOAPHeaderElement> it = soapHeader.getChildElements();
        // TODO: not sure if the order of the header additions is or should be preserved.
        // in other words, this test may be a little too strict.
        SOAPHeaderElement headerElem1 = it.next();
        SOAPHeaderElement headerElem2 = it.next();
        // should only be two header elements, so...
        assertFalse(it.hasNext());
        
        assertTrue(headerElem1.toString().equals(acoh1));
        assertTrue(headerElem2.toString().equals(acoh2));
        
        // now that we've done a toString() on the header elements, they've been parsed and
        // processed by the underlying OM implementation...  let's remove one by way of SOAP
        // API, then let's make sure we can still get and manipulate the headers via the
        // SOAPHeadersAdapter
        
        // TODO:  removeChild gives an exception
        //soapHeader.removeChild(headerElem1);
        headerElem1.detachNode();
        
        // one is removed, make sure the SOAPHeadersAdapter reflects the change
        
        List<String> contentListAfterSOAPRemoval = adapter.get(ACOH1_HEADER_QNAME);
        assertTrue(contentListAfterSOAPRemoval.size() == 1);
        // remember we removed headerElem1, so we expect acoh2 to still exist
        assertTrue(contentListAfterSOAPRemoval.get(0).equals(acoh2));
        
	}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:60,代碼來源:SOAPHeadersAdapterTests.java

示例8: testAddRemoveAsSOAPEnvelope

import javax.xml.soap.SOAPHeader; //導入方法依賴的package包/類
public void testAddRemoveAsSOAPEnvelope() throws Exception {

		MessageContext messageContext = getMessageContext();
		
		SOAPHeadersAdapter.install(messageContext);
		
    	SOAPFactory sf = SOAPFactory.newInstance();
    	
    	// QName used here should match the key for the list set on the requestCtx
    	SOAPElement e1 = sf.createElement(ACOH1_HEADER_QNAME);
    	e1.addTextNode(CONTENT_STRING1);
    	String acoh1 = e1.toString();
    	
    	// QName used here should match the key for the list set on the requestCtx
    	SOAPElement e2 = sf.createElement(ACOH1_HEADER_QNAME);
    	e2.addTextNode(CONTENT_STRING2);
    	String acoh2 = e2.toString();

        List<String> acoh1ContentList = new ArrayList<String>();
        acoh1ContentList.add(acoh1);
        acoh1ContentList.add(acoh2);
        
        SOAPHeadersAdapter adapter = (SOAPHeadersAdapter)messageContext.getProperty(Constants.JAXWS_OUTBOUND_SOAP_HEADERS);
        
        adapter.put(ACOH1_HEADER_QNAME, acoh1ContentList);
        
        // get message object and convert to SOAPEnvelope
        SOAPEnvelope soapEnvelope = messageContext.getMessage().getAsSOAPEnvelope();
        
        // confirm headers are there
        SOAPHeader soapHeader = soapEnvelope.getHeader();
        Iterator<SOAPHeaderElement> it = soapHeader.getChildElements();
        // TODO: not sure if the order of the header additions is or should be preserved.
        // in other words, this test may be a little too strict.
        SOAPHeaderElement headerElem1 = it.next();
        SOAPHeaderElement headerElem2 = it.next();
        // should only be two header elements, so...
        assertFalse(it.hasNext());
        
        assertTrue(headerElem1.toString().equals(acoh1));
        assertTrue(headerElem2.toString().equals(acoh2));
        
        // now that we've done a toString() on the header elements, they've been parsed and
        // processed by the underlying OM implementation...  let's remove one by way of SOAP
        // API, then let's make sure we can still get and manipulate the headers via the
        // SOAPHeadersAdapter
        
        // TODO:  removeChild gives an exception
        //soapHeader.removeChild(headerElem1);
        headerElem1.detachNode();
        
        // one is removed, make sure the SOAPHeadersAdapter reflects the change
        
        List<String> contentListAfterSOAPRemoval = adapter.get(ACOH1_HEADER_QNAME);
        assertTrue(contentListAfterSOAPRemoval.size() == 1);
        // remember we removed headerElem1, so we expect acoh2 to still exist
        assertTrue(contentListAfterSOAPRemoval.get(0).equals(acoh2));
        
	}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:60,代碼來源:SOAPHeadersAdapterTests.java

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