Java Code Examples for org.apache.axiom.om.OMElement#addChild()

The following examples show how to use org.apache.axiom.om.OMElement#addChild() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TransformPayloadWhenArgsValueAndExpressionTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
private OMElement getPlaceOrderPayload(String symbolValue) {
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace omNs = fac.createOMNamespace("http://services.samples", "ser");
    OMNamespace xsdNs = fac.createOMNamespace("http://services.samples", "xsd");
    OMElement payload = fac.createOMElement("placeOrder", omNs);
    OMElement order = fac.createOMElement("order", omNs);

    OMElement price = fac.createOMElement("price", xsdNs);
    price.setText("invalid");
    OMElement quantity = fac.createOMElement("quantity", xsdNs);
    quantity.setText("invalid");
    OMElement symbol = fac.createOMElement("symbol", xsdNs);
    symbol.setText(symbolValue);

    order.addChild(price);
    order.addChild(quantity);
    order.addChild(symbol);
    payload.addChild(order);
    return payload;
}
 
Example 2
Source File: RetrieveDocumentSetResponse.java    From openxds with Apache License 2.0 6 votes vote down vote up
public OMElement getResponse() throws XdsInternalException {
	OMElement response = MetadataSupport.om_factory.createOMElement(new QName(MetadataSupport.xdsB_uri, "RetrieveDocumentSetResponse"));
	
	response.addChild(rr.getResponse());
	
	//Add DocumentResponse
	for(OMElement docResponse : documentResponses) {
		response.addChild(docResponse);		
	}
	
	if (log.isDebugEnabled()) {
		log.debug("response is \n" + response.toString());
	}
	
	return response;
}
 
Example 3
Source File: Sample702TestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
private OMElement createPayload() {   // creation of payload for placeOrder

        OMFactory fac = OMAbstractFactory.getOMFactory();
        OMNamespace omNs = fac.createOMNamespace("http://services.samples", "ser");
        OMNamespace xsdNs = fac.createOMNamespace("http://services.samples", "xsd");
        OMElement payload = fac.createOMElement("placeOrder", omNs);
        OMElement order = fac.createOMElement("order", omNs);

        OMElement price = fac.createOMElement("price", xsdNs);
        price.setText("10");
        OMElement quantity = fac.createOMElement("quantity", xsdNs);
        quantity.setText("100");
        OMElement symbol = fac.createOMElement("symbol", xsdNs);
        symbol.setText("WSO2");

        order.addChild(price);
        order.addChild(quantity);
        order.addChild(symbol);
        payload.addChild(order);
        return payload;
    }
 
Example 4
Source File: FileServiceTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@Test(groups = {"wso2.dss"})
public void createNewFile() throws AxisFault, XPathExpressionException {
    OMElement response;
    OMElement payload;

    payload = fac.createOMElement("_getcreatenewfile", omNs);

    OMElement fileName = fac.createOMElement("fileName", omNs);
    fileName.setText(txtFileName);
    payload.addChild(fileName);

    OMElement fileType = fac.createOMElement("fileType", omNs);
    fileType.setText(txtFileType);
    payload.addChild(fileType);

    new AxisServiceClient().sendRobust(payload, getServiceUrlHttp(serviceName), "_getcreatenewfile");
    response = checkFileExists();
    Assert.assertEquals("1", response.getFirstElement().getFirstElement().getText(), "Expected Not same .File Not Exists");
    log.info("New File Created");


}
 
Example 5
Source File: XdsRegistryLifeCycleServiceTest.java    From openxds with Apache License 2.0 6 votes vote down vote up
/**
	 * Create a new SubmitObjectsRequest as an Axiom OMElement
	 * 
	 * @param submissionSet
	 *            The xds submission set for the request
	 * @param documentEntries
	 *            The xds document entries for the request
	 * @param connection
	 *            The connection that will be used for the request
	 * @throws XdsRimException
	 *             When the metadata cannot be encoded into a valid ebRIM
	 *             XML
	 */
private OMElement getsubmitObjectsRequest() {
	
	OMElement submitObjectsRequest = helper.omFactory.createOMElement("SubmitObjectsRequest", helper.nsLcm);
	submitObjectsRequest.declareNamespace(helper.ns);
	submitObjectsRequest.declareNamespace(helper.nsXsi);
	submitObjectsRequest.declareNamespace(helper.nsLcm);
	submitObjectsRequest.declareNamespace(helper.nsRim);		
	submitObjectsRequest.declareNamespace(helper.nsRs);
	//submitObjectsRequest.addAttribute("schemaLocation", XDS_b_REGISTRY_SCHEMA_LOCATION, nsXsi);
	try {
		OMElement registryObjectList = helper.omFactory().createOMElement("RegistryObjectList", helper.nsRim);
		submitObjectsRequest.addChild(registryObjectList);
		String docId = "urn:uuid:0520abda-8944-4463-b715-844a6785f2ab";
		registryObjectList.addChild(getExtrinsicObject(docId, "text/xml"));
		String setId = "urn:uuid:08e6330f-1a7d-4099-be06-96cf8e6edae2";
		registryObjectList.addChild(getRegistryPackage(setId));
		RimAxiom.addRimClassificationElement(registryObjectList, "cl-ss0", setId, XDS_SUBMISSION_SET, helper.nsRim);
		// Link the document entries to the submission set
		RimAxiom.addRimSubmissionDocumentAssociationElement(registryObjectList, setId, docId, helper.nsRim);

	} catch (Exception e) {
		log.debug(e.getMessage());
	}
	return submitObjectsRequest;
}
 
Example 6
Source File: ServiceInvoker.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
public void addDummyElements(long numElements) {
    OMElement dummies = fac.createOMElement("Dummies", null);
    msg.addChild(dummies);

    for (long i = 0; i < numElements; i++) {
        OMElement dummy = fac.createOMElement("Dummy", null);
        dummy.setText("This is the dummy element " + i);
        dummies.addChild(dummy);
    }
}
 
Example 7
Source File: EnrichIntegrationReplaceEnvelopeTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
private OMElement createQuoteRequestBody(String symbol) {
    SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
    OMNamespace omNs = fac.createOMNamespace("http://services.samples", "ns");
    OMElement method = fac.createOMElement("getQuote", omNs);

    OMElement value1 = fac.createOMElement("request", omNs);
    OMElement value2 = fac.createOMElement("symbol", omNs);
    value2.addChild(fac.createOMText(value1, symbol));
    value1.addChild(value2);
    method.addChild(value1);

    return method;
}
 
Example 8
Source File: DiscoveryOMUtils.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
/**
 * Serializes the given TargetService instance into XML using the provided OMFactory.
 * The serialized XML content is attached to the provided parent element. Therefore
 * the parent element must not be null when invoking this method.
 *
 * @param service TargetService to be serialized
 * @param factory OMFactory to be used for creating XML objects
 * @param parent The parent element to which the TargetService will be attached
 * @return The parent element with the serialized TargetService content
 * @throws DiscoveryException If an error occurs while serializing XML content
 */
public static OMElement toOM(TargetService service, OMFactory factory,
                             OMElement parent) throws DiscoveryException {
    try {
        OMElement epr = EndpointReferenceHelper.toOM(factory, service.getEpr(),
                AddressingConstants.Final.WSA_ENDPOINT_REFERENCE,
                AddressingConstants.Final.WSA_NAMESPACE);
        parent.addChild(epr);

        if (service.getTypes() != null && service.getTypes().length > 0) {
            parent.addChild(serializeQNamesList(service.getTypes(), DiscoveryConstants.TYPES,
                    factory));
        }

        if (service.getScopes() != null && service.getScopes().length > 0) {
            parent.addChild(serializeURIList(service.getScopes(), DiscoveryConstants.SCOPES,
                    factory));
        }

        if (service.getXAddresses() != null && service.getXAddresses().length > 0) {
            parent.addChild(serializeURIList(service.getXAddresses(),
                    DiscoveryConstants.XADDRESSES, factory));
        }

        if (service.getMetadataVersion() != -1) {
            OMElement metaVersion = factory.createOMElement(DiscoveryConstants.METADATA_VERSION);
            metaVersion.setText(String.valueOf(service.getMetadataVersion()));
            parent.addChild(metaVersion);
        }

    } catch (AxisFault axisFault) {
        handleFault("Error while serializing the target service description " +
                "into XML", axisFault);
    }

    return parent;
}
 
Example 9
Source File: EnrichIntegrationReplaceEnvelopeWithPropertyTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
private OMElement createQuoteRequestBody(String symbol) {
    SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
    OMNamespace omNs = fac.createOMNamespace("http://services.samples", "ns");
    OMElement method = fac.createOMElement("getQuote", omNs);

    OMElement value1 = fac.createOMElement("request", omNs);
    OMElement value2 = fac.createOMElement("symbol", omNs);
    value2.addChild(fac.createOMText(value1, symbol));
    value1.addChild(value2);
    method.addChild(value1);

    return method;
}
 
Example 10
Source File: ConcurrencyThrottleTestClient.java    From product-ei with Apache License 2.0 5 votes vote down vote up
private OMElement getSleepOperationRequest() throws XMLStreamException {
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMElement omeSleep = fac.createOMElement("sleepOperation", null);
    OMElement omeLoad = fac.createOMElement("load", null);
    omeLoad.setText("2000");
    omeSleep.addChild(omeLoad);
    return omeSleep;

}
 
Example 11
Source File: DataServiceSqlDriverTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
private OMElement deleteRecord(String idNum) {
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace omNs = fac.createOMNamespace("http://ws.wso2.org/dataservice", "dat");
    OMElement payload = fac.createOMElement("delete", omNs);
    OMElement id = fac.createOMElement("id", omNs);
    id.setText(idNum);
    payload.addChild(id);

    return payload;
}
 
Example 12
Source File: Util.java    From openxds with Apache License 2.0 5 votes vote down vote up
static void test1() throws XdsInternalException, FactoryConfigurationError {
	String x = "<foo/>";
	OMElement x_ele = Util.parse_xml(x);
	OMElement y_ele = Util.deep_copy(x_ele);
	if (!y_ele.getLocalName().equals("foo"))
		System.out.println("test1 fails, name is " + y_ele.getLocalName());
	OMElement z_ele = Util.parse_xml("<z/>");
	z_ele.addChild(y_ele);
	System.out.println("test1: " + z_ele.toString());
}
 
Example 13
Source File: QueryFactory.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private static void addRHSChildrenToLHS(OMElement lhs, OMElement rhs) {
	Iterator<OMElement> itr = rhs.getChildElements();
	OMElement el;
	while (itr.hasNext()) {
		el = itr.next();
		lhs.addChild(el);
	}
}
 
Example 14
Source File: IterateSOAPActionTest.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private OMElement createSimpleQuoteRequestBody(String symbol) {
    SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
    OMNamespace omNs = fac.createOMNamespace("http://services.samples", "ns");
    OMElement method = fac.createOMElement("getQuote", omNs);
    OMElement value1 = fac.createOMElement("request", omNs);
    OMElement value2 = fac.createOMElement("symbol", omNs);
    value2.addChild(fac.createOMText(value1, symbol));
    value1.addChild(value2);
    method.addChild(value1);
    return method;
}
 
Example 15
Source File: IterateClient.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private OMElement createSimpleQuoteRequestBody(String symbol) {
    SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
    OMNamespace omNs = fac.createOMNamespace("http://services.samples", "ns");
    OMElement method = fac.createOMElement("getQuote", omNs);
    OMElement value1 = fac.createOMElement("request", omNs);
    OMElement value2 = fac.createOMElement("symbol", omNs);
    value2.addChild(fac.createOMText(value1, symbol));
    value1.addChild(value2);
    method.addChild(value1);
    return method;
}
 
Example 16
Source File: SampleDataServiceClient.java    From product-ei with Apache License 2.0 5 votes vote down vote up
public OMElement getEmployeeById(String employeeNumber)
        throws AxisFault {
    OMElement payload = fac.createOMElement("employeesByNumber", omNs);

    OMElement empNo = fac.createOMElement("employeeNumber", omNs);
    empNo.setText(employeeNumber);
    payload.addChild(empNo);

    OMElement result = new AxisServiceClient().sendReceive(payload, serviceEndpoint, "employeesByNumber");
    return result;
}
 
Example 17
Source File: ErrorManager.java    From openxds with Apache License 2.0 4 votes vote down vote up
void addElement(OMElement root, String name, String value) {
	OMElement ele = MetadataSupport.om_factory.createOMElement(name, null);
	ele.setText(value.replace("<", "[").replace(">", "]"));
	root.addChild(ele);
}
 
Example 18
Source File: QuerySerializer.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
private static void serializeSparqlQueryProps(SparqlQueryBase sparqlQuery, OMElement queryEl, OMFactory fac) {
	OMElement sparqlEl = fac.createOMElement(new QName(DBSFields.SPARQL));
	sparqlEl.setText(sparqlQuery.getQuery());
	queryEl.addChild(sparqlEl);
}
 
Example 19
Source File: PayloadFormatWithArgumentsTestCase.java    From product-ei with Apache License 2.0 3 votes vote down vote up
private OMElement createPayload() {   // creation of payload for echoString

        SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();

        OMNamespace omNs = fac.createOMNamespace("http://service.carbon.wso2.org", "ns");
        OMElement operation = fac.createOMElement("echoString", omNs);
        OMElement getName = fac.createOMElement("s", omNs);

        getName.addChild(fac.createOMText(getName, "name"));
        operation.addChild(getName);

        return operation;
    }
 
Example 20
Source File: DistributedTransactionTestCase.java    From product-ei with Apache License 2.0 3 votes vote down vote up
private OMElement getAccountBalanceFromBank2(int accId) {
    OMElement payload = fac.createOMElement("getAccountBalanceFromBank2", omNs);

    OMElement accountId = fac.createOMElement("accountId", omNs);
    accountId.setText(accId + "");
    payload.addChild(accountId);

    return payload;

}