本文整理汇总了Java中org.apache.axiom.om.OMElement.addAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java OMElement.addAttribute方法的具体用法?Java OMElement.addAttribute怎么用?Java OMElement.addAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.axiom.om.OMElement
的用法示例。
在下文中一共展示了OMElement.addAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTokenCancelerConfigParameter
import org.apache.axiom.om.OMElement; //导入方法依赖的package包/类
public static Parameter getTokenCancelerConfigParameter() {
OMFactory fac = OMAbstractFactory.getOMFactory();
OMElement paramElem = fac.createOMElement(new QName("parameter"), null);
paramElem.addAttribute(fac.createOMAttribute("name",
null,
TokenCancelerConfig.TOKEN_CANCELER_CONFIG.
getLocalPart()));
paramElem.addAttribute(fac.createOMAttribute("type",
null, Integer.toString(Parameter.OM_PARAMETER).
toString()));
fac.createOMElement(TokenCancelerConfig.TOKEN_CANCELER_CONFIG,
paramElem);
Parameter param = new Parameter();
param.setName(TokenCancelerConfig.TOKEN_CANCELER_CONFIG.getLocalPart());
param.setParameterElement(paramElem);
param.setValue(paramElem);
param.setParameterType(Parameter.OM_PARAMETER);
return param;
}
示例2: getPayload
import org.apache.axiom.om.OMElement; //导入方法依赖的package包/类
private OMElement getPayload() {
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNsa = fac.createOMNamespace("testns1", "a");
OMNamespace omNsb = fac.createOMNamespace("testns2", "b");
OMNamespace omNsc = fac.createOMNamespace("testns3", "c");
OMElement payload = fac.createOMElement("test", omNsa);
OMElement p1 = fac.createOMElement("testb", omNsb);
OMAttribute a1 = fac.createOMAttribute("attrb1", omNsa, "a");
a1.setAttributeValue("v1");
p1.addAttribute(a1);
OMAttribute a2 = fac.createOMAttribute("attrb2", omNsb, "b");
a2.setAttributeValue("v2");
p1.addAttribute(a2);
OMElement p2 = fac.createOMElement("testc", omNsc);
p1.addChild(p2);
payload.addChild(p1);
return payload;
}
示例3: sendError
import org.apache.axiom.om.OMElement; //导入方法依赖的package包/类
private void sendError(HttpServletResponse res, Object object, String serviceName) throws EventHandlerException {
try {
// setup the response
res.setContentType("text/xml");
String xmlResults= SoapSerializer.serialize(object);
XMLStreamReader xmlReader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(xmlResults));
StAXOMBuilder resultsBuilder = new StAXOMBuilder(xmlReader);
OMElement resultSer = resultsBuilder.getDocumentElement();
// create the response soap
SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
SOAPEnvelope resEnv = factory.createSOAPEnvelope();
SOAPBody resBody = factory.createSOAPBody();
OMElement errMsg = factory.createOMElement(new QName((serviceName != null ? serviceName : "") + "Response"));
errMsg.addChild(resultSer.getFirstElement());
resBody.addChild(errMsg);
resEnv.addChild(resBody);
// The declareDefaultNamespace method doesn't work see (https://issues.apache.org/jira/browse/AXIS2-3156)
// so the following doesn't work:
// resService.declareDefaultNamespace(ModelService.TNS);
// instead, create the xmlns attribute directly:
OMAttribute defaultNS = factory.createOMAttribute("xmlns", null, ModelService.TNS);
errMsg.addAttribute(defaultNS);
// log the response message
if (Debug.verboseOn()) {
try {
Debug.logInfo("Response Message:\n" + resEnv + "\n", module);
} catch (Throwable t) {
}
}
resEnv.serialize(res.getOutputStream());
res.getOutputStream().flush();
} catch (Exception e) {
throw new EventHandlerException(e.getMessage(), e);
}
}
示例4: updateSecondaryUserStore
import org.apache.axiom.om.OMElement; //导入方法依赖的package包/类
/**
* Encrypts the secondary user store configuration
*
* @param secondaryStoreDocument OMElement of respective file path
* @param cipher Cipher object read for super-tenant's key store
* @throws UserStoreConfigurationDeployerException If update operation failed
*/
private void updateSecondaryUserStore(OMElement secondaryStoreDocument, Cipher cipher) throws
UserStoreConfigurationDeployerException {
String className = secondaryStoreDocument.getAttributeValue(new QName(UserStoreConfigurationConstants.PROPERTY_CLASS));
ArrayList<String> encryptList = getEncryptPropertyList(className);
Iterator<?> ite = secondaryStoreDocument.getChildrenWithName(new QName(UserStoreConfigurationConstants.PROPERTY));
while (ite.hasNext()) {
OMElement propElem = (OMElement) ite.next();
if (propElem != null && (propElem.getText() != null)) {
String propertyName = propElem.getAttributeValue(new QName(UserStoreConfigurationConstants.PROPERTY_NAME));
OMAttribute encryptedAttr = propElem.getAttribute(new QName(UserStoreConfigurationConstants
.PROPERTY_ENCRYPTED));
if (encryptedAttr == null) {
boolean encrypt = encryptList.contains(propertyName) || isEligibleTobeEncrypted(propElem);
if (encrypt) {
OMAttribute encryptAttr = propElem.getAttribute(new QName(UserStoreConfigurationConstants.PROPERTY_ENCRYPT));
if (encryptAttr != null) {
propElem.removeAttribute(encryptAttr);
}
try {
String cipherText = Base64.encode(cipher.doFinal((propElem.getText().getBytes())));
propElem.setText(cipherText);
propElem.addAttribute(UserStoreConfigurationConstants.PROPERTY_ENCRYPTED, "true", null);
} catch (GeneralSecurityException e) {
String errMsg = "Encryption in secondary user store failed";
throw new UserStoreConfigurationDeployerException(errMsg, e);
}
}
}
}
}
}
示例5: getParameters
import org.apache.axiom.om.OMElement; //导入方法依赖的package包/类
public final OMElement getParameters() {
OMFactory omFactory = OMAbstractFactory.getOMFactory();
OMElement parameters = omFactory.createOMElement("parameters", null);
for (Map.Entry<Integer, Integer> e : this.users.entrySet()) {
OMElement user = omFactory.createOMElement("user_item", null);
user.addAttribute("id", e.getKey().toString(), null);
user.addAttribute("version", e.getValue().toString(), null);
parameters.addChild(user);
}
return parameters;
}
示例6: toOMElement
import org.apache.axiom.om.OMElement; //导入方法依赖的package包/类
public OMElement toOMElement(){
OMFactory omFactory = OMAbstractFactory.getOMFactory();
OMElement element = omFactory.createOMElement(this.elementName, null);
element.addAttribute("user_id", String.valueOf(this.userId), null);
element.addAttribute("name", this.name, null);
element.addAttribute("date", DateUtil.dateToString(this.date), null);
return element;
}
示例7: insertTimestampNullTest
import org.apache.axiom.om.OMElement; //导入方法依赖的package包/类
/**
* Method to test insertion of timestamp value.
*
* @throws Exception
*/
@Test(groups = {"wso2.dss"}, description = "insert null value as timestamp value and check it's successful", alwaysRun = true)
public void insertTimestampNullTest() throws Exception {
OMElement insertTimeStampPayload = fac.createOMElement("addDeveloper", omNs);
OMNamespace nullNameSpace = fac.createOMNamespace("http://www.w3.org/2001/XMLSchema-instance", "xsi");
insertTimeStampPayload.declareNamespace(nullNameSpace);
OMElement devId = fac.createOMElement("devId", omNs);
devId.setText(2 + "");
insertTimeStampPayload.addChild(devId);
OMElement devName = fac.createOMElement("devName", omNs);
devName.setText("name2");
insertTimeStampPayload.addChild(devName);
OMElement devdob = fac.createOMElement("devdob", omNs);
OMAttribute nullAttribute = fac.createOMAttribute("nil", nullNameSpace,"true");
devdob.addAttribute(nullAttribute);
insertTimeStampPayload.addChild(devdob);
new AxisServiceClient().sendRobust(insertTimeStampPayload, getServiceUrlHttp(serviceName), "addDeveloper");
OMElement getDeveloperByIdPayload = fac.createOMElement("select_developers_by_id_operation", omNs);
getDeveloperByIdPayload.addChild(devId);
//retrieve and see whether inserted correctly
OMElement responseProduct = new AxisServiceClient().sendReceive(getDeveloperByIdPayload, getServiceUrlHttp(serviceName), "select_developers_by_id_operation");
assertNotNull(responseProduct, "Response null " + responseProduct);
assertTrue(responseProduct.toString().contains("<devdob"), "'devdob' should have exist in the response");
log.info("Insert TimeStamp Operation Success");
}
示例8: getHeader
import org.apache.axiom.om.OMElement; //导入方法依赖的package包/类
private OMElement getHeader(OMFactory factory) {
OMElement header = factory.createOMElement("header", null);
OMElement msgType = factory.createOMElement("field", null);
msgType.addAttribute(factory.createOMAttribute("id", null, "35"));
factory.createOMText(msgType, "D");
header.addChild(msgType);
OMElement sendingTime = factory.createOMElement("field", null);
sendingTime.addAttribute(factory.createOMAttribute("id", null, "52"));
factory.createOMText(sendingTime, new Date().toString());
header.addChild(sendingTime);
return header;
}
示例9: getBody
import org.apache.axiom.om.OMElement; //导入方法依赖的package包/类
private OMElement getBody(OMFactory factory, String text, String mode, String qtyValue) {
OMElement body = factory.createOMElement("body", null);
OMElement clordID = factory.createOMElement("field", null);
clordID.addAttribute(factory.createOMAttribute("id", null, "11"));
factory.createOMText(clordID, "122333");
body.addChild(clordID);
OMElement handleIns = factory.createOMElement("field", null);
handleIns.addAttribute(factory.createOMAttribute("id", null, "21"));
factory.createOMText(handleIns, "1");
body.addChild(handleIns);
OMElement qty = factory.createOMElement("field", null);
qty.addAttribute(factory.createOMAttribute("id", null, "38"));
factory.createOMText(qty, qtyValue);
body.addChild(qty);
OMElement ordType = factory.createOMElement("field", null);
ordType.addAttribute(factory.createOMAttribute("id", null, "40"));
factory.createOMText(ordType, "1");
body.addChild(ordType);
OMElement side = factory.createOMElement("field", null);
side.addAttribute(factory.createOMAttribute("id", null, "54"));
factory.createOMText(side, mode);
body.addChild(side);
OMElement symbol = factory.createOMElement("field", null);
symbol.addAttribute(factory.createOMAttribute("id", null, "55"));
factory.createOMText(symbol, text);
body.addChild(symbol);
OMElement timeInForce = factory.createOMElement("field", null);
timeInForce.addAttribute(factory.createOMAttribute("id", null, "59"));
factory.createOMText(timeInForce, "0");
body.addChild(timeInForce);
return body;
}
示例10: getHeader
import org.apache.axiom.om.OMElement; //导入方法依赖的package包/类
private static OMElement getHeader(OMFactory factory) {
OMElement header = factory.createOMElement("header", null);
OMElement msgType = factory.createOMElement("field", null);
msgType.addAttribute(factory.createOMAttribute("id", null, "35"));
factory.createOMText(msgType, "D");
header.addChild(msgType);
OMElement sendingTime = factory.createOMElement("field", null);
sendingTime.addAttribute(factory.createOMAttribute("id", null, "52"));
factory.createOMText(sendingTime, new Date().toString());
header.addChild(sendingTime);
return header;
}
示例11: getBody
import org.apache.axiom.om.OMElement; //导入方法依赖的package包/类
private static OMElement getBody(OMFactory factory, String text, String mode, String qtyValue) {
OMElement body = factory.createOMElement("body", null);
OMElement clordID = factory.createOMElement("field", null);
clordID.addAttribute(factory.createOMAttribute("id", null, "11"));
factory.createOMText(clordID, "122333");
body.addChild(clordID);
OMElement handleIns = factory.createOMElement("field", null);
handleIns.addAttribute(factory.createOMAttribute("id", null, "21"));
factory.createOMText(handleIns, "1");
body.addChild(handleIns);
OMElement qty = factory.createOMElement("field", null);
qty.addAttribute(factory.createOMAttribute("id", null, "38"));
factory.createOMText(qty, qtyValue);
body.addChild(qty);
OMElement ordType = factory.createOMElement("field", null);
ordType.addAttribute(factory.createOMAttribute("id", null, "40"));
factory.createOMText(ordType, "1");
body.addChild(ordType);
OMElement side = factory.createOMElement("field", null);
side.addAttribute(factory.createOMAttribute("id", null, "54"));
factory.createOMText(side, mode);
body.addChild(side);
OMElement symbol = factory.createOMElement("field", null);
symbol.addAttribute(factory.createOMAttribute("id", null, "55"));
factory.createOMText(symbol, text);
body.addChild(symbol);
OMElement timeInForce = factory.createOMElement("field", null);
timeInForce.addAttribute(factory.createOMAttribute("id", null, "59"));
factory.createOMText(timeInForce, "0");
body.addChild(timeInForce);
return body;
}
示例12: nfeToOMElement
import org.apache.axiom.om.OMElement; //导入方法依赖的package包/类
private OMElement nfeToOMElement(final String documento) throws XMLStreamException {
final OMElement ome = AXIOMUtil.stringToOM(documento);
final Iterator<?> children = ome.getChildrenWithLocalName(WSLoteEnvio.NFE_ELEMENTO);
while (children.hasNext()) {
final OMElement omElement = (OMElement) children.next();
if ((omElement != null) && (WSLoteEnvio.NFE_ELEMENTO.equals(omElement.getLocalName()))) {
omElement.addAttribute("xmlns", NFeConfig.NFE_NAMESPACE, null);
}
}
return ome;
}
示例13: enviar
import org.apache.axiom.om.OMElement; //导入方法依赖的package包/类
/**
* Metodo para Enviar
*
* @param TEnviCTe
* @return TRetEnviCTe
* @throws CteException
*/
private static CteRecepcaoLoteResult enviar(String xml, String tipo) throws CteException {
try {
/**
* Informacoes do Certificado Digital.
*/
CertificadoUtil.iniciaConfiguracoes();
ConfiguracoesIniciais configuracoesCte = ConfiguracoesIniciais.getInstance();
OMElement ome = AXIOMUtil.stringToOM(xml);
if(configuracoesCte.getEstado().equals(Estados.PR)){
Iterator children = ome.getChildrenWithLocalName("CTe");
while (children.hasNext()) {
OMElement omElement = (OMElement) children.next();
if (omElement != null && "CTe".equals(omElement.getLocalName())) {
omElement.addAttribute("xmlns", "http://www.portalfiscal.inf.br/cte", null);
}
}
}
if (configuracoesCte.isLog()) {
System.out.println("Cte para Envio: " + ome.toString());
}
CteDadosMsg dadosMsg = new CteDadosMsg();
dadosMsg.setExtraElement(ome);
CteCabecMsg cteCabecMsg = new CteCabecMsg();
/**
* Codigo do Estado.
*/
cteCabecMsg.setCUF(String.valueOf(configuracoesCte.getEstado().getCodigoIbge()));
/**
* Versao do XML
*/
cteCabecMsg.setVersaoDados(configuracoesCte.getVersao());
CteCabecMsgE cteCabecMsgE = new CteCabecMsgE();
cteCabecMsgE.setCteCabecMsg(cteCabecMsg);
CteRecepcaoStub stub = new CteRecepcaoStub(WebServiceUtil.getUrl(tipo, ConstantesCte.SERVICOS.ENVIO_CTE));
return stub.cteRecepcaoLote(dadosMsg, cteCabecMsgE);
} catch (RemoteException | XMLStreamException e) {
throw new CteException(e.getMessage());
}
}
示例14: createAndSendSOAPResponse
import org.apache.axiom.om.OMElement; //导入方法依赖的package包/类
private void createAndSendSOAPResponse(Map<String, Object> serviceResults, String serviceName, HttpServletResponse response) throws EventHandlerException {
try {
// setup the response
Debug.logVerbose("[EventHandler] : Setting up response message", module);
String xmlResults = SoapSerializer.serialize(serviceResults);
//Debug.logInfo("xmlResults ==================" + xmlResults, module);
XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(xmlResults));
StAXOMBuilder resultsBuilder = new StAXOMBuilder(reader);
OMElement resultSer = resultsBuilder.getDocumentElement();
// create the response soap
SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
SOAPEnvelope resEnv = factory.createSOAPEnvelope();
SOAPBody resBody = factory.createSOAPBody();
OMElement resService = factory.createOMElement(new QName(serviceName + "Response"));
resService.addChild(resultSer.getFirstElement());
resBody.addChild(resService);
resEnv.addChild(resBody);
// The declareDefaultNamespace method doesn't work see (https://issues.apache.org/jira/browse/AXIS2-3156)
// so the following doesn't work:
// resService.declareDefaultNamespace(ModelService.TNS);
// instead, create the xmlns attribute directly:
OMAttribute defaultNS = factory.createOMAttribute("xmlns", null, ModelService.TNS);
resService.addAttribute(defaultNS);
// log the response message
if (Debug.verboseOn()) {
try {
Debug.logInfo("Response Message:\n" + resEnv + "\n", module);
} catch (Throwable t) {
}
}
resEnv.serialize(response.getOutputStream());
response.getOutputStream().flush();
} catch (Exception e) {
Debug.logError(e, module);
throw new EventHandlerException(e.getMessage(), e);
}
}
示例15: getSCTIssuerConfigParameter
import org.apache.axiom.om.OMElement; //导入方法依赖的package包/类
public static Parameter getSCTIssuerConfigParameter(String cryptoImpl,
Properties cryptoProperties,
int keyComputation,
String proofKeyType,
boolean addRequestedAttachedRef,
boolean addRequestedUnattachedRef) throws Exception {
if (cryptoImpl == null || "".equals(cryptoImpl)) {
throw new Exception("Crypto impl missing");
}
OMFactory fac = OMAbstractFactory.getOMFactory();
OMElement paramElem = fac.createOMElement(new QName("parameter"), null);
paramElem.addAttribute(fac.createOMAttribute("name",
null,
SCTIssuerConfig.SCT_ISSUER_CONFIG.
getLocalPart()));
paramElem.addAttribute(fac.createOMAttribute("type",
null, Integer.toString(Parameter.OM_PARAMETER)));
OMElement elem = fac.createOMElement(
SCTIssuerConfig.SCT_ISSUER_CONFIG, paramElem);
OMElement cryptoPropElem = fac.createOMElement(
AbstractIssuerConfig.CRYPTO_PROPERTIES, elem);
OMElement cryptoElem = fac.createOMElement(
AbstractIssuerConfig.CRYPTO, cryptoPropElem);
cryptoElem.addAttribute(fac.createOMAttribute("provider", null,
cryptoImpl));
Enumeration keysEnum = cryptoProperties.keys();
while (keysEnum.hasMoreElements()) {
String key = (String) keysEnum.nextElement();
OMElement prop = fac.createOMElement(new QName("property"), cryptoElem);
prop.addAttribute(fac.createOMAttribute("name", null, key));
prop.setText(cryptoProperties.getProperty(key));
}
if (!(keyComputation == AbstractIssuerConfig.KeyComputation.KEY_COMP_PROVIDE_ENT ||
keyComputation == AbstractIssuerConfig.KeyComputation.KEY_COMP_USE_OWN_KEY ||
keyComputation == AbstractIssuerConfig.KeyComputation.KEY_COMP_USE_REQ_ENT)) {
keyComputation = AbstractIssuerConfig.KeyComputation.KEY_COMP_USE_OWN_KEY;
}
OMElement keyCompElem = fac.createOMElement(
AbstractIssuerConfig.KeyComputation.KEY_COMPUTATION, elem);
keyCompElem.setText(Integer.toString(keyComputation));
if (proofKeyType == null || "".equals(proofKeyType)) {
proofKeyType = TokenIssuerUtil.BINARY_SECRET;
} else if (!(TokenIssuerUtil.BINARY_SECRET.equals(proofKeyType)) ||
TokenIssuerUtil.ENCRYPTED_KEY.equals(proofKeyType)) {
throw new Exception("Invalid proof token type configuration : " + proofKeyType);
}
OMElement proofKeyTypeElem = fac.createOMElement(AbstractIssuerConfig.PROOF_KEY_TYPE, elem);
proofKeyTypeElem.setText(proofKeyType);
if (addRequestedAttachedRef) {
fac.createOMElement(AbstractIssuerConfig.ADD_REQUESTED_ATTACHED_REF, elem);
}
if (addRequestedUnattachedRef) {
fac.createOMElement(AbstractIssuerConfig.ADD_REQUESTED_UNATTACHED_REF, elem);
}
Parameter param = new Parameter();
param.setName(SCTIssuerConfig.SCT_ISSUER_CONFIG.getLocalPart());
param.setParameterType(Parameter.OM_PARAMETER);
param.setValue(paramElem);
param.setParameterElement(paramElem);
return param;
}