本文整理汇总了Java中javax.xml.soap.SOAPHeaderElement.addChildElement方法的典型用法代码示例。如果您正苦于以下问题:Java SOAPHeaderElement.addChildElement方法的具体用法?Java SOAPHeaderElement.addChildElement怎么用?Java SOAPHeaderElement.addChildElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.soap.SOAPHeaderElement
的用法示例。
在下文中一共展示了SOAPHeaderElement.addChildElement方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleRequest
import javax.xml.soap.SOAPHeaderElement; //导入方法依赖的package包/类
/**
* Adds an "Access" element to the SOAP header
*/
public boolean handleRequest(MessageContext msgct) {
if (msgct instanceof SOAPMessageContext) {
SOAPMessageContext smsgct = (SOAPMessageContext) msgct;
try {
SOAPMessage msg = smsgct.getMessage();
SOAPEnvelope envelope = msg.getSOAPPart().getEnvelope();
SOAPHeader header = msg.getSOAPHeader();
if (header == null)
header = envelope.addHeader(); // add an header if non exists
SOAPHeaderElement accessElement = header.addHeaderElement(envelope.createName("Access", "ns0", JPLAG_TYPES_NS));
SOAPElement usernameelem = accessElement.addChildElement("username");
usernameelem.addTextNode(username);
SOAPElement passwordelem = accessElement.addChildElement("password");
passwordelem.addTextNode(password);
SOAPElement compatelem = accessElement.addChildElement("compatLevel");
compatelem.addTextNode(compatibilityLevel + "");
} catch (SOAPException x) {
System.out.println("Unable to create access SOAP header!");
x.printStackTrace();
}
}
return true;
}
示例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(new QName(getNamespaceURI(), getLocalPart()));
she.addChildElement(actionLocalName);
she.addTextNode(action);
if (soapAction != null) {
she.addChildElement(soapActionLocalName);
she.addTextNode(soapAction);
}
}
示例3: addUpgradeHeaderElement
import javax.xml.soap.SOAPHeaderElement; //导入方法依赖的package包/类
@Override
public SOAPHeaderElement addUpgradeHeaderElement(Iterator supportedSoapUris)
throws SOAPException {
if (supportedSoapUris == null) {
log.severe("SAAJ0411.ver1_2.no.null.supportedURIs");
throw new SOAPException("Argument cannot be null; iterator of supportedURIs cannot be null");
}
if (!supportedSoapUris.hasNext()) {
log.severe("SAAJ0412.ver1_2.no.empty.list.of.supportedURIs");
throw new SOAPException("List of supported URIs cannot be empty");
}
Name upgradeName = getUpgradeName();
SOAPHeaderElement upgradeHeaderElement =
(SOAPHeaderElement) addChildElement(upgradeName);
Name supportedEnvelopeName = getSupportedEnvelopeName();
int i = 0;
while (supportedSoapUris.hasNext()) {
SOAPElement subElement =
upgradeHeaderElement.addChildElement(supportedEnvelopeName);
String ns = "ns" + Integer.toString(i);
subElement.addAttribute(
NameImpl.createFromUnqualifiedName("qname"),
ns + ":Envelope");
subElement.addNamespaceDeclaration(
ns, (String) supportedSoapUris.next());
i ++;
}
return upgradeHeaderElement;
}
示例4: 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);
}
示例5: getMessageToSign
import javax.xml.soap.SOAPHeaderElement; //导入方法依赖的package包/类
private static final SOAPMessage getMessageToSign(final String pathBase)
throws SOAPException, IOException {
final SOAPMessage soapMessage;
final SOAPPart soapPart;
final SOAPEnvelope soapEnvelope;
final SOAPHeader soapHeader;
final SOAPHeaderElement secElement;
final SOAPElement binaryTokenElement;
soapMessage = SoapMessageUtils.getMessage(pathBase);
soapPart = soapMessage.getSOAPPart();
soapEnvelope = soapPart.getEnvelope();
soapHeader = soapEnvelope.getHeader();
secElement = soapHeader.addHeaderElement(soapEnvelope.createName(
"Security", "wsse",
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"));
binaryTokenElement = secElement.addChildElement(soapEnvelope.createName(
"BinarySecurityToken", "wsse",
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"));
binaryTokenElement.setAttribute("EncodingType",
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary");
binaryTokenElement.setAttribute("ValueType",
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3");
return soapMessage;
}
示例6: handleRequest
import javax.xml.soap.SOAPHeaderElement; //导入方法依赖的package包/类
/**
* Adds an "Access" element to the SOAP header
*/
public boolean handleRequest(MessageContext msgct) {
if(msgct instanceof SOAPMessageContext) {
SOAPMessageContext smsgct=(SOAPMessageContext) msgct;
try {
SOAPMessage msg=smsgct.getMessage();
SOAPEnvelope envelope=msg.getSOAPPart().getEnvelope();
SOAPHeader header=msg.getSOAPHeader();
if(header==null)
header=envelope.addHeader(); // add an header if non exists
SOAPHeaderElement accessElement=header.addHeaderElement(
envelope.createName("Access","ns0",
"http://www.ipd.uni-karlsruhe.de/jplag/types"));
SOAPElement usernameelem=accessElement.addChildElement(
"username");
usernameelem.addTextNode(username);
SOAPElement passwordelem=accessElement.addChildElement(
"password");
passwordelem.addTextNode(password);
SOAPElement compatelem=accessElement.addChildElement(
"compatLevel");
compatelem.addTextNode(compatibilityLevel+"");
} catch (SOAPException x) {
System.out.println("Unable to create access SOAP header!");
x.printStackTrace();
}
}
return true;
}
示例7: SOAPMessageContextMock
import javax.xml.soap.SOAPHeaderElement; //导入方法依赖的package包/类
private SOAPMessageContextMock(boolean isOutbound) throws SOAPException {
MessageFactory factory = MessageFactory.newInstance();
this.message = factory.createMessage();
this.isOutbound = isOutbound;
if (!isOutbound) {
SOAPHeader header = this.message.getSOAPHeader();
SOAPHeaderElement authenticationHeaderElement =
header.addHeaderElement(
AuthenticationHandler.authenticationHeaderName);
SOAPElement authenticationTokenElement =
authenticationHeaderElement.addChildElement(
AuthenticationHandler.authenticationTokenName);
authenticationTokenElement.addTextNode("incoming token");
}
}
示例8: 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();
}
}
示例9: 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();
}
}
示例10: createSOAPPart
import javax.xml.soap.SOAPHeaderElement; //导入方法依赖的package包/类
private void createSOAPPart(SOAPMessage message) throws SOAPException {
SOAPPart sPart = message.getSOAPPart();
SOAPEnvelope env = sPart.getEnvelope();
SOAPBody body = env.getBody();
final SOAPHeader soapHeader = env.getHeader();
soapHeader
.addHeaderElement(env.createName("TestHeader1", "swa", "http://fakeNamespace.org"));
soapHeader
.addHeaderElement(env.createName("TestHeader2", "swa", "http://fakeNamespace.org"));
final SOAPHeaderElement headerEle3 =
soapHeader.addHeaderElement(
env.createName("TestHeader3", "swa", "http://fakeNamespace.org"));
final SOAPElement ch1 = headerEle3.addChildElement("he3", "swa");
ch1.addTextNode("Im Header Element of header3");
Name ns = env.createName("echo", "swa", "http://fakeNamespace.org");
SOAPBodyElement bodyElement = body.addBodyElement(ns);
Name nameMain = env.createName("internal");
SOAPElement mainChildEle = bodyElement.addChildElement(nameMain);
Name ns2 = env.createName("text");
SOAPElement textReference = mainChildEle.addChildElement(ns2);
Name hrefAttr = env.createName("href");
textReference.addAttribute(hrefAttr, "cid:[email protected]");
Name ns3 = env.createName("image");
SOAPElement imageReference = mainChildEle.addChildElement(ns3);
Name ns31 = env.createName("inner");
final SOAPElement img = imageReference.addChildElement(ns31);
img.addAttribute(hrefAttr, "cid:[email protected]");
Name ns4 = env.createName("plaintxt");
SOAPElement plainTxt = mainChildEle.addChildElement(ns4);
plainTxt.addTextNode("This is simple plain text");
Name ns5 = env.createName("nested");
SOAPElement nested = mainChildEle.addChildElement(ns5);
nested.addTextNode("Nested1 Plain Text");
Name ns6 = env.createName("nested2");
SOAPElement nested2 = nested.addChildElement(ns6);
nested2.addTextNode("Nested2 Plain Text");
}