本文整理汇总了Java中javax.xml.soap.SOAPHeaderElement.setMustUnderstand方法的典型用法代码示例。如果您正苦于以下问题:Java SOAPHeaderElement.setMustUnderstand方法的具体用法?Java SOAPHeaderElement.setMustUnderstand怎么用?Java SOAPHeaderElement.setMustUnderstand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.soap.SOAPHeaderElement
的用法示例。
在下文中一共展示了SOAPHeaderElement.setMustUnderstand方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testHeaderElements
import javax.xml.soap.SOAPHeaderElement; //导入方法依赖的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: writeTo
import javax.xml.soap.SOAPHeaderElement; //导入方法依赖的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);
}
示例3: decorateHeader
import javax.xml.soap.SOAPHeaderElement; //导入方法依赖的package包/类
private void decorateHeader(SOAPEnvelope envelope, String username, String passwordHash) throws Exception {
SOAPHeader header = envelope.getHeader();
SOAPHeaderElement security = header.addHeaderElement(new QName("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "Security", "wsse"));
security.addNamespaceDeclaration("wsse", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
security.setMustUnderstand(true);
SOAPElement usrToken = security.addChildElement("UsernameToken", "wsse");
usrToken.addAttribute(new QName("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd", "Id", "wsu"), "UsernameToken-27777511");
SOAPElement usr = usrToken.addChildElement("Username", "wsse");
usr.setTextContent(username);
SOAPElement password = usrToken.addChildElement("Password", "wsse");
password.setAttribute("Type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText");
password.setTextContent(passwordHash);
}
示例4: ebSetup
import javax.xml.soap.SOAPHeaderElement; //导入方法依赖的package包/类
public static void ebSetup(SOAPEnvelope envelope,
String frparty,
String toparty,
String cpaId,
String conversId,
String service,
String action
) {
try {
SOAPHeader header = envelope.getHeader();
SOAPHeaderElement ebHeader = header.addHeaderElement(
envelope.createName("MessageHeader", NS_PREFIX_EB, NS_URI_EB));
ebHeader.setMustUnderstand(true);
ebHeader.addAttribute(envelope.createName("version"), "1.0");
SOAPElement ebFrom = ebHeader.addChildElement(
envelope.createName("From", NS_PREFIX_EB, NS_URI_EB));
SOAPElement ebPartyFrom = ebFrom.addChildElement(
envelope.createName("PartyId", NS_PREFIX_EB, NS_URI_EB));
ebPartyFrom.addTextNode(frparty);
SOAPElement ebTo = ebHeader.addChildElement(
envelope.createName("To", NS_PREFIX_EB, NS_URI_EB));
SOAPElement ebPartyTo = ebTo.addChildElement(
envelope.createName("PartyId", NS_PREFIX_EB, NS_URI_EB));
ebPartyTo.addTextNode(toparty);
SOAPElement ebCPAId = ebHeader.addChildElement(
envelope.createName("CPAId", NS_PREFIX_EB, NS_URI_EB));
ebCPAId.addTextNode(cpaId);
SOAPElement ebConv = ebHeader.addChildElement(
envelope.createName("ConversationId"
, NS_PREFIX_EB, NS_URI_EB));
ebConv.addTextNode(conversId);
SOAPElement ebService = ebHeader.addChildElement(
envelope.createName("Service", NS_PREFIX_EB, NS_URI_EB));
ebService.addTextNode(service);
SOAPElement ebAction = ebHeader.addChildElement(
envelope.createName("Action", NS_PREFIX_EB, NS_URI_EB));
ebAction.addTextNode(action);
SOAPElement ebMesData = ebHeader.addChildElement(
envelope.createName("MessageData", NS_PREFIX_EB, NS_URI_EB));
SOAPElement ebMesId = ebMesData.addChildElement(
envelope.createName("MessageId", NS_PREFIX_EB, NS_URI_EB));
ebMesId.addTextNode(System.currentTimeMillis() + "");
SOAPElement ebMesTime = ebMesData.addChildElement(
envelope.createName("Timestamp", NS_PREFIX_EB, NS_URI_EB));
ebMesTime.addTextNode(new Date().toString());
} catch(Exception e) {
e.printStackTrace();
}
}
示例5: ebSetup
import javax.xml.soap.SOAPHeaderElement; //导入方法依赖的package包/类
private void ebSetup(SOAPEnvelope envelope,
String frparty,
String toparty,
String cpaId,
String conversId,
String service,
String action
) {
try {
SOAPHeader header = envelope.getHeader();
SOAPHeaderElement ebHeader = header.addHeaderElement(
envelope.createName("MessageHeader", NS_PREFIX_EB, NS_URI_EB));
ebHeader.setMustUnderstand(true);
ebHeader.addAttribute(envelope.createName("version"), "1.0");
SOAPElement ebFrom = ebHeader.addChildElement(
envelope.createName("From", NS_PREFIX_EB, NS_URI_EB));
SOAPElement ebPartyFrom = ebFrom.addChildElement(
envelope.createName("PartyId", NS_PREFIX_EB, NS_URI_EB));
ebPartyFrom.addTextNode(frparty);
SOAPElement ebTo = ebHeader.addChildElement(
envelope.createName("To", NS_PREFIX_EB, NS_URI_EB));
SOAPElement ebPartyTo = ebTo.addChildElement(
envelope.createName("PartyId", NS_PREFIX_EB, NS_URI_EB));
ebPartyTo.addTextNode(toparty);
SOAPElement ebCPAId = ebHeader.addChildElement(
envelope.createName("CPAId", NS_PREFIX_EB, NS_URI_EB));
ebCPAId.addTextNode(cpaId);
SOAPElement ebConv = ebHeader.addChildElement(
envelope.createName("ConversationId"
, NS_PREFIX_EB, NS_URI_EB));
ebConv.addTextNode(conversId);
SOAPElement ebService = ebHeader.addChildElement(
envelope.createName("Service", NS_PREFIX_EB, NS_URI_EB));
ebService.addTextNode(service);
SOAPElement ebAction = ebHeader.addChildElement(
envelope.createName("Action", NS_PREFIX_EB, NS_URI_EB));
ebAction.addTextNode(action);
SOAPElement ebMesData = ebHeader.addChildElement(
envelope.createName("MessageData", NS_PREFIX_EB, NS_URI_EB));
SOAPElement ebMesId = ebMesData.addChildElement(
envelope.createName("MessageId", NS_PREFIX_EB, NS_URI_EB));
ebMesId.addTextNode(System.currentTimeMillis() + "");
SOAPElement ebMesTime = ebMesData.addChildElement(
envelope.createName("Timestamp", NS_PREFIX_EB, NS_URI_EB));
ebMesTime.addTextNode(new Date().toString());
} catch(Exception e) {
e.printStackTrace();
}
}
示例6: getSOAPMessage
import javax.xml.soap.SOAPHeaderElement; //导入方法依赖的package包/类
/**
* This method handles the conversion of an OM SOAP Envelope to a SAAJ SOAPMessage
*
* @param respOMSoapEnv
* @return the SAAJ SOAPMessage
* @throws SOAPException If an exception occurs during this conversion
*/
private SOAPMessage getSOAPMessage(org.apache.axiom.soap.SOAPEnvelope respOMSoapEnv)
throws SOAPException {
// Create the basic SOAP Message
MessageFactory mf = MessageFactory.newInstance();
SOAPMessage response = mf.createMessage();
SOAPPart sPart = response.getSOAPPart();
javax.xml.soap.SOAPEnvelope env = sPart.getEnvelope();
SOAPBody body = env.getBody();
SOAPHeader header = env.getHeader();
// Convert all header blocks
org.apache.axiom.soap.SOAPHeader header2 = respOMSoapEnv.getHeader();
if (header2 != null) {
for (Iterator hbIter = header2.examineAllHeaderBlocks(); hbIter.hasNext();) {
// Converting a single OM SOAP HeaderBlock to a SAAJ SOAP
// HeaderBlock
org.apache.axiom.soap.SOAPHeaderBlock hb = (org.apache.axiom.soap.SOAPHeaderBlock)
hbIter.next();
final QName hbQName = hb.getQName();
final SOAPHeaderElement headerEle = header.addHeaderElement(env.createName(hbQName
.getLocalPart(), hbQName.getPrefix(), hbQName.getNamespaceURI()));
for (Iterator attribIter = hb.getAllAttributes(); attribIter.hasNext();) {
OMAttribute attr = (OMAttribute)attribIter.next();
final QName attrQName = attr.getQName();
headerEle.addAttribute(env.createName(attrQName.getLocalPart(), attrQName
.getPrefix(), attrQName.getNamespaceURI()), attr.getAttributeValue());
}
final String role = hb.getRole();
if (role != null) {
headerEle.setActor(role);
}
headerEle.setMustUnderstand(hb.getMustUnderstand());
toSAAJElement(headerEle, hb, response);
}
}
// Convert the body
toSAAJElement(body, respOMSoapEnv.getBody(), response);
return response;
}
示例7: testHeaders
import javax.xml.soap.SOAPHeaderElement; //导入方法依赖的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);
}
}