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


Java SOAPHeader.examineAllHeaderElements方法代碼示例

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


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

示例1: initHeaderUnderstanding

import javax.xml.soap.SOAPHeader; //導入方法依賴的package包/類
/** Set the initial understood/not understood state of the headers in this
 * object
 */
private void initHeaderUnderstanding() {
    SOAPHeader soapHeader = ensureSOAPHeader();
    if (soapHeader == null) {
        return;
    }

    Iterator allHeaders = soapHeader.examineAllHeaderElements();
    while(allHeaders.hasNext()) {
        SOAPHeaderElement nextHdrElem = (SOAPHeaderElement) allHeaders.next();
        if (nextHdrElem == null) {
            continue;
        }
        if (nextHdrElem.getMustUnderstand()) {
            notUnderstood(nextHdrElem.getElementQName());
        }
        //only headers explicitly marked as understood should be
        //in the understoodHeaders set, so don't add anything to
        //that set at the beginning
    }

}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:25,代碼來源:SAAJMessageHeaders.java

示例2: addSoapMetaInfo

import javax.xml.soap.SOAPHeader; //導入方法依賴的package包/類
protected Map<String,String> addSoapMetaInfo(Map<String, String> metaInfo, SOAPMessage soapMessage)
        throws SOAPException {
    SOAPHeader soapHeader = soapMessage.getSOAPHeader();
    if (soapHeader == null) {
        return metaInfo;
    }
    else {
        Map<String, String> newMetaInfo = new HashMap<String, String>();
        newMetaInfo.putAll(metaInfo);
        Iterator<?> iter = soapHeader.examineAllHeaderElements();
        while (iter.hasNext()) {
            SOAPHeaderElement headerElem = (SOAPHeaderElement) iter.next();
            if (!Listener.AUTHENTICATED_USER_HEADER.equals(headerElem.getNodeName()))
                newMetaInfo.put(headerElem.getNodeName(), headerElem.getTextContent());
        }
        return newMetaInfo;
    }
}
 
開發者ID:CenturyLinkCloud,項目名稱:mdw,代碼行數:19,代碼來源:SoapServlet.java

示例3: getOperationFromSOAPHdr

import javax.xml.soap.SOAPHeader; //導入方法依賴的package包/類
private String getOperationFromSOAPHdr(SOAPHeader soapHeader) {
@SuppressWarnings("unchecked")
Iterator<SOAPHeaderElement> it = soapHeader.examineAllHeaderElements();

SOAPHeaderElement opHdr = null;

while (it.hasNext()) {
    opHdr = it.next();

    if ("operation".equals(opHdr.getLocalName())) {
	System.out.println("Found operation in SOAP header");

	return opHdr.getTextContent();
    }
}

return null;
   }
 
開發者ID:asarkar,項目名稱:jax-ws,代碼行數:19,代碼來源:JAXWSProviderService.java

示例4: parse

import javax.xml.soap.SOAPHeader; //導入方法依賴的package包/類
private void parse() {
    if (!parsedMessage) {
        try {
            access();
            if (headers == null)
                headers = new HeaderList();
            SOAPHeader header = sm.getSOAPHeader();
            if (header != null) {
                headerAttrs = header.getAttributes();
                Iterator iter = header.examineAllHeaderElements();
                while (iter.hasNext()) {
                    headers.add(new SAAJHeader((SOAPHeaderElement) iter.next()));
                }
            }
            attachmentSet = new SAAJAttachmentSet(sm);

            parsedMessage = true;
        } catch (SOAPException e) {
            throw new WebServiceException(e);
        }
    }
}
 
開發者ID:alexkasko,項目名稱:openjdk-icedtea7,代碼行數:23,代碼來源:SAAJMessage.java

示例5: getHeaders

import javax.xml.soap.SOAPHeader; //導入方法依賴的package包/類
@Override
public Iterator<Header> getHeaders(final String nsUri, final String localName,
        final boolean markAsUnderstood) {
    SOAPHeader soapHeader = ensureSOAPHeader();
    if (soapHeader == null) {
        return null;
    }
    Iterator allHeaders = soapHeader.examineAllHeaderElements();
    if (markAsUnderstood) {
        //mark all the matchingheaders as understood up front
        //make an iterator while we're doing that
        List<Header> headers = new ArrayList<Header>();
        while (allHeaders.hasNext()) {
            SOAPHeaderElement nextHdr = (SOAPHeaderElement) allHeaders.next();
            if (nextHdr != null &&
                    nextHdr.getNamespaceURI().equals(nsUri)) {
                if (localName == null ||
                        nextHdr.getLocalName().equals(localName)) {
                    understood(nextHdr.getNamespaceURI(), nextHdr.getLocalName());
                    headers.add(new SAAJHeader(nextHdr));
                }
            }
        }
        return headers.iterator();
    }
    //if we got here markAsUnderstood is false - return a lazy iterator rather
    //than traverse the entire list of headers now
    return new HeaderReadIterator(allHeaders, nsUri, localName);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:30,代碼來源:SAAJMessageHeaders.java

示例6: find

import javax.xml.soap.SOAPHeader; //導入方法依賴的package包/類
private SOAPHeaderElement find(String nsUri, String localName) {
    SOAPHeader soapHeader = ensureSOAPHeader();
    if (soapHeader == null) {
        return null;
    }
    Iterator allHeaders = soapHeader.examineAllHeaderElements();
    while(allHeaders.hasNext()) {
        SOAPHeaderElement nextHdrElem = (SOAPHeaderElement) allHeaders.next();
        if (nextHdrElem.getNamespaceURI().equals(nsUri) &&
                nextHdrElem.getLocalName().equals(localName)) {
            return nextHdrElem;
        }
    }
    return null;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:16,代碼來源:SAAJMessageHeaders.java

示例7: hasHeaders

import javax.xml.soap.SOAPHeader; //導入方法依賴的package包/類
@Override
public boolean hasHeaders() {
    SOAPHeader soapHeader = ensureSOAPHeader();
    if (soapHeader == null) {
        return false;
    }

    Iterator allHeaders = soapHeader.examineAllHeaderElements();
    return allHeaders.hasNext();
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:11,代碼來源:SAAJMessageHeaders.java

示例8: asList

import javax.xml.soap.SOAPHeader; //導入方法依賴的package包/類
@Override
public List<Header> asList() {
    SOAPHeader soapHeader = ensureSOAPHeader();
    if (soapHeader == null) {
        return Collections.emptyList();
    }

    Iterator allHeaders = soapHeader.examineAllHeaderElements();
    List<Header> headers = new ArrayList<Header>();
    while (allHeaders.hasNext()) {
        SOAPHeaderElement nextHdr = (SOAPHeaderElement) allHeaders.next();
        headers.add(new SAAJHeader(nextHdr));
    }
    return headers;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:16,代碼來源:SAAJMessageHeaders.java

示例9: extractSoapResponseHeaders

import javax.xml.soap.SOAPHeader; //導入方法依賴的package包/類
protected void extractSoapResponseHeaders(SOAPHeader header) throws TransformerException {
    Map<Name,String> soapHeaders = new HashMap<Name,String>();
    Iterator<?> iter = header.examineAllHeaderElements();
    while (iter.hasNext()) {
        SOAPHeaderElement headerElem = (SOAPHeaderElement) iter.next();
        soapHeaders.put(headerElem.getElementName(), headerElem.getTextContent());
    }
    setSoapResponseHeaders(soapHeaders);
}
 
開發者ID:CenturyLinkCloud,項目名稱:mdw,代碼行數:10,代碼來源:SoapWebServiceAdapter.java

示例10: extractUsername

import javax.xml.soap.SOAPHeader; //導入方法依賴的package包/類
/**
 * Extracts the username out of the header of a SOAP message
 */
public static String extractUsername(SOAPMessageContext smsg) {
	try {
		SOAPHeader header = smsg.getMessage().getSOAPHeader();
		if (header != null) {
			@SuppressWarnings("unchecked")
			Iterator<SOAPHeaderElement> headers = header.examineAllHeaderElements();
			while (headers.hasNext()) {
				SOAPHeaderElement he = headers.next();

				if (he.getElementName().getLocalName().equals("Access")) {
					@SuppressWarnings("unchecked")
					Iterator<SOAPElement> elements = he.getChildElements();
					while (elements.hasNext()) {
						SOAPElement e = elements.next();
						String name = e.getElementName().getLocalName();
						if (name.equals("username"))
							return e.getValue();
					}
				}
			}
		}
	} catch (SOAPException x) {
		x.printStackTrace();
	}
	return null;
}
 
開發者ID:jplag,項目名稱:jplag,代碼行數:30,代碼來源:JPlagServerAccessHandler.java

示例11: testUnmarshall_Simple

import javax.xml.soap.SOAPHeader; //導入方法依賴的package包/類
/**
 * Test method for {@link io.apiman.gateway.engine.io.SoapPayloadIO#unmarshall(java.io.InputStream)}.
 */
@Test
public void testUnmarshall_Simple() throws Exception {
    String xml = "<?xml version=\"1.0\"?>\r\n" + 
            "<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\">\r\n" + 
            "  <soap:Header>\r\n" + 
            "     <ns1:CustomHeader xmlns:ns1=\"urn:ns1\">CVALUE</ns1:CustomHeader>\r\n" + 
            "  </soap:Header>\r\n" + 
            "  <soap:Body>\r\n" + 
            "    <m:GetStockPrice xmlns:m=\"http://www.example.org/stock/Surya\">\r\n" + 
            "      <m:StockName>IBM</m:StockName>\r\n" + 
            "    </m:GetStockPrice>\r\n" + 
            "  </soap:Body>\r\n" + 
            "</soap:Envelope>";
    byte [] xmlBytes = xml.getBytes();
    SoapPayloadIO io = new SoapPayloadIO();
    try (InputStream is = new ByteArrayInputStream(xmlBytes)) {
        SOAPEnvelope envelope = io.unmarshall(is);
        Assert.assertNotNull(envelope);
        Assert.assertEquals("Envelope", envelope.getLocalName());
        Assert.assertEquals("http://www.w3.org/2003/05/soap-envelope", envelope.getNamespaceURI());
        
        SOAPHeader header = envelope.getHeader();
        Assert.assertNotNull(header);
        
        Iterator allHeaderElements = header.examineAllHeaderElements();
        Assert.assertTrue(allHeaderElements.hasNext());
        SOAPHeaderElement cheader = (SOAPHeaderElement) allHeaderElements.next();
        Assert.assertNotNull(cheader);
        Assert.assertEquals("CVALUE", cheader.getTextContent());
    }
}
 
開發者ID:apiman,項目名稱:apiman,代碼行數:35,代碼來源:SoapPayloadIOTest.java

示例12: checkHeader

import javax.xml.soap.SOAPHeader; //導入方法依賴的package包/類
private void checkHeader(SOAPHeader header)
{
    Iterator<SOAPHeaderElement> headers = header.examineAllHeaderElements();
    assertTrue("no headers found", headers.hasNext());

    Map<QName, SOAPHeaderElement> elements = new HashMap<QName, SOAPHeaderElement>();
    while (headers.hasNext()) {
        SOAPHeaderElement element = headers.next();
        elements.put(new QName(element.getNamespaceURI(), element.getLocalName()), element);
    }

    SOAPHeaderElement counterKey = elements.get(new QName("http://counter.com", "CounterKey"));
    assertNotNull("Could not find {http://counter.com}CounterKey header", counterKey);
    assertEquals("15063581", counterKey.getTextContent());

    SOAPHeaderElement difficultChild = elements.get(new QName("http://difficult.com/", "one"));
    assertNotNull("Could not find {http://difficult.com/}one header", difficultChild);

    assertEquals("something", difficultChild.getAttributeNS("http://difficult.com/","attrib"));
    assertEquals("else", difficultChild.getAttributeNS(null, "attrib"));

    Iterator<SOAPElement> difficultFishes = difficultChild.getChildElements(new QName("http://difficult.com/", "fish"));
    assertTrue("no {http://difficult.com/}fish element found", difficultFishes.hasNext());
    SOAPElement difficultFish = difficultFishes.next();
    assertFalse("more than one {http://difficult.com/}fish element found", difficultFishes.hasNext());

    Iterator<SOAPElement> counterFishes = difficultFish.getChildElements(new QName("http://counter.com", "fish"));
    assertTrue("no {http://counter.com}fish element found", counterFishes.hasNext());
    SOAPElement counterFish = counterFishes.next();
    assertFalse("more than one {http://counter.com}fish element found", counterFishes.hasNext());

    SOAPHeaderElement emptyNamespace = elements.get(new QName("emptyNamespace"));
    assertNotNull("Could not find {}emptyNamespace header", emptyNamespace);

    Iterator<SOAPElement> defaultNamespaces = emptyNamespace.getChildElements(new QName("http://default/", "defaultNamespace"));
    assertTrue("no {http://default/}defaultNamespace element found", defaultNamespaces.hasNext());
    SOAPElement defaultNamespace = defaultNamespaces.next();
    assertFalse("more than one {http://default/}defaultNamespace element found", defaultNamespaces.hasNext());

    Iterator<SOAPElement> stillEmpties = emptyNamespace.getChildElements(new QName("stillEmpty"));
    assertTrue("no {}stillEmpty element found", stillEmpties.hasNext());
    SOAPElement stillEmpty = stillEmpties.next();
    assertFalse("more than one {}stillEmpty element found", stillEmpties.hasNext());
}
 
開發者ID:apache,項目名稱:incubator-taverna-common-activities,代碼行數:45,代碼來源:WSRFActivityTest.java

示例13: testHeaders

import javax.xml.soap.SOAPHeader; //導入方法依賴的package包/類
@Validated @Test
public void testHeaders() {
    try {
        // Create message factory and SOAP factory
        MessageFactory messageFactory = MessageFactory.newInstance();
        SOAPFactory soapFactory = SOAPFactory.newInstance();

        // Create a message
        SOAPMessage message = messageFactory.createMessage();

        // Get the SOAP header from the message and
        //  add headers to it
        SOAPHeader header = message.getSOAPHeader();

        String nameSpace = "ns";
        String nameSpaceURI = "http://gizmos.com/NSURI";

        Name order =
                soapFactory.createName("orderDesk", nameSpace, nameSpaceURI);
        SOAPHeaderElement orderHeader = header.addHeaderElement(order);
        orderHeader.setActor("http://gizmos.com/orders");

        Name shipping =
                soapFactory.createName("shippingDesk", nameSpace, nameSpaceURI);
        SOAPHeaderElement shippingHeader =
                header.addHeaderElement(shipping);
        shippingHeader.setActor("http://gizmos.com/shipping");

        Name confirmation =
                soapFactory.createName("confirmationDesk", nameSpace,
                                       nameSpaceURI);
        SOAPHeaderElement confirmationHeader =
                header.addHeaderElement(confirmation);
        confirmationHeader.setActor("http://gizmos.com/confirmations");

        Name billing =
                soapFactory.createName("billingDesk", nameSpace, nameSpaceURI);
        SOAPHeaderElement billingHeader = header.addHeaderElement(billing);
        billingHeader.setActor("http://gizmos.com/billing");

        // Add header with mustUnderstand attribute
        Name tName =
                soapFactory.createName("Transaction", "t",
                                       "http://gizmos.com/orders");

        SOAPHeaderElement transaction = header.addHeaderElement(tName);
        transaction.setMustUnderstand(true);
        transaction.addTextNode("5");

        // Get the SOAP body from the message but leave
        // it empty
        SOAPBody body = message.getSOAPBody();

        message.saveChanges();

        // Display the message that would be sent
        //System.out.println("\n----- Request Message ----\n");
        //message.writeTo(System.out);

        // Look at the headers
        Iterator allHeaders = header.examineAllHeaderElements();

        while (allHeaders.hasNext()) {
            SOAPHeaderElement headerElement =
                    (SOAPHeaderElement)allHeaders.next();
            Name headerName = headerElement.getElementName();
            //System.out.println("\nHeader name is " +
            //                   headerName.getQualifiedName());
            //System.out.println("Actor is " + headerElement.getActor());
            //System.out.println("mustUnderstand is " +
            //                   headerElement.getMustUnderstand());
        }
    } catch (Exception e) {
        fail("Enexpected Exception " + e);
    }
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:77,代碼來源:SOAPHeaderTest.java


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