本文整理匯總了Java中javax.xml.soap.SOAPHeader.extractHeaderElements方法的典型用法代碼示例。如果您正苦於以下問題:Java SOAPHeader.extractHeaderElements方法的具體用法?Java SOAPHeader.extractHeaderElements怎麽用?Java SOAPHeader.extractHeaderElements使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.xml.soap.SOAPHeader
的用法示例。
在下文中一共展示了SOAPHeader.extractHeaderElements方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testHeaderElements
import javax.xml.soap.SOAPHeader; //導入方法依賴的package包/類
@Validated @Test
public void testHeaderElements() throws Exception {
SOAPEnvelope envelope = getSOAPEnvelope();
SOAPHeader header = envelope.getHeader();
SOAPHeaderElement headerEle = header.addHeaderElement(envelope.createName("foo1",
"f1",
"foo1-URI"));
headerEle.setActor("actor-URI");
headerEle.setMustUnderstand(true);
Iterator iterator = header.extractHeaderElements("actor-URI");
int cnt = 0;
while (iterator.hasNext()) {
cnt++;
SOAPHeaderElement resultHeaderEle = (SOAPHeaderElement)iterator.next();
assertEquals(headerEle.getActor(), resultHeaderEle.getActor());
assertEquals(resultHeaderEle.getMustUnderstand(), headerEle.getMustUnderstand());
}
assertTrue(cnt == 1);
iterator = header.extractHeaderElements("actor-URI");
assertTrue(!iterator.hasNext());
}
示例2: parseApiVersion
import javax.xml.soap.SOAPHeader; //導入方法依賴的package包/類
public static String parseApiVersion(SOAPMessageContext context)
throws SOAPException {
SOAPMessage soapMessage = context.getMessage();
SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope();
SOAPHeader soapHeader = soapEnvelope.getHeader();
if (soapHeader == null) {
return "";
}
Iterator<?> it = null;
Iterator<?> itCm = soapHeader.extractHeaderElements(VERSION_CM);
if (itCm == null || !itCm.hasNext()) {
Iterator<?> itCtmg = soapHeader.extractHeaderElements(VERSION_CTMG);
if (itCtmg == null || !itCtmg.hasNext()) {
return "";
} else {
it = itCtmg;
}
} else {
it = itCm;
}
Node node = (Node) it.next();
String value = node == null ? null : node.getValue();
return value;
}