Java Code Examples for org.apache.axiom.om.OMAbstractFactory#getOMFactory()
The following examples show how to use
org.apache.axiom.om.OMAbstractFactory#getOMFactory() .
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: SQLDriverGspreadSheetTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
private OMElement updateCustomer() { OMFactory fac = OMAbstractFactory.getOMFactory(); OMNamespace omNs = fac .createOMNamespace("http://ws.wso2.org/dataservice/samples/" + "gspread_sql_driver_sample_service", "gsp"); OMElement updateCustomerSQL = fac.createOMElement("updateCustomerSQL", omNs); OMElement customerNumber = fac.createOMElement("customerNumber", omNs); OMElement contactLastName = fac.createOMElement("contactLastName", omNs); OMElement contactFirstName = fac.createOMElement("contactFirstName", omNs); customerNumber.setText(inputValue); contactLastName.setText(inputValue + "updated"); contactFirstName.setText(inputValue + "updated"); updateCustomerSQL.addChild(customerNumber); updateCustomerSQL.addChild(contactLastName); updateCustomerSQL.addChild(contactFirstName); return updateCustomerSQL; }
Example 2
Source File: CSVDataServiceTestCase.java From product-ei with Apache License 2.0 | 6 votes |
@Test(groups = {"wso2.dss"}, invocationCount = 5) public void selectOperation() throws AxisFault, XPathExpressionException { OMFactory fac = OMAbstractFactory.getOMFactory(); OMNamespace omNs = fac.createOMNamespace("http://ws.wso2.org/dataservice/samples/csv_sample_service", "ns1"); OMElement payload = fac.createOMElement("getProducts", omNs); OMElement result = new AxisServiceClient().sendReceive(payload, getServiceUrlHttp(serviceName), "getProducts"); Assert.assertTrue((result.toString().indexOf("Products") == 1), "Expected Result not found on response message"); Assert.assertTrue(result.toString().contains("<Product>"), "Expected Result not found on response message"); Assert.assertTrue(result.toString().contains("<ID>"), "Expected Result not found on response message"); Assert.assertTrue(result.toString().contains("<Category>"), "Expected Result not found on response message"); Assert.assertTrue(result.toString().contains("<Price>"), "Expected Result not found on response message"); Assert.assertTrue(result.toString().contains("<Name>"), "Expected Result not found on response message"); log.info("Service invocation success"); }
Example 3
Source File: AGSpreadDataServiceTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
@Test(groups = { "wso2.dss" }, invocationCount = 5, enabled = false) public void selectOperation() throws AxisFault, XPathExpressionException { OMFactory fac = OMAbstractFactory.getOMFactory(); OMNamespace omNs = fac .createOMNamespace("http://ws.wso2.org/dataservice/samples/gspread_sample_service", "ns1"); OMElement payload = fac.createOMElement("getCustomers", omNs); OMElement result = new AxisServiceClient().sendReceive(payload, getServiceUrlHttp(serviceName), "getcustomers"); log.info("Response : " + result); Assert.assertTrue((result.toString().indexOf("Customers") == 1), "Expected Result not found on response message"); Assert.assertTrue(result.toString().contains("<customerNumber>"), "Expected Result not found on response message"); Assert.assertTrue(result.toString().contains("</Customer>"), "Expected Result not found on response message"); log.info("Service Invocation success"); }
Example 4
Source File: RahasUtil.java From carbon-identity with Apache License 2.0 | 6 votes |
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; }
Example 5
Source File: StockQuoteHandler.java From micro-integrator with Apache License 2.0 | 6 votes |
/** * Create a new order for a quantiry of a stock at a given price * <m:placeOrder xmlns:m="http://services.samples"> * <m:order> * <m:price>3.141593E0</m:price> * <m:quantity>4</m:quantity> * <m:symbol>IBM</m:symbol> * </m:order> * </m:placeOrder> * * @param purchPrice the purchase price * @param qty the quantiry * @param symbol the stock * @return an OMElement payload for the order */ public static OMElement createPlaceOrderRequest(double purchPrice, int qty, String symbol) { OMFactory factory = OMAbstractFactory.getOMFactory(); OMNamespace ns = factory.createOMNamespace("http://services.samples", "m0"); OMElement placeOrder= factory.createOMElement("placeOrder", ns); OMElement order = factory.createOMElement("order", ns); OMElement price = factory.createOMElement("price", ns); OMElement quantity = factory.createOMElement("quantity", ns); OMElement symb = factory.createOMElement("symbol", ns); price.setText(Double.toString(purchPrice)); quantity.setText(Integer.toString(qty)); symb.setText(symbol); order.addChild(price); order.addChild(quantity); order.addChild(symb); placeOrder.addChild(order); return placeOrder; }
Example 6
Source File: StockQuoteClient.java From micro-integrator with Apache License 2.0 | 6 votes |
/** * Create place order request * * @param purchasePrice purchase price * @param qty quantity * @param symbol symbol * @return OMElement of request */ public OMElement createPlaceOrderRequest(double purchasePrice, int qty, String symbol) { OMFactory factory = OMAbstractFactory.getOMFactory(); OMNamespace ns = factory.createOMNamespace("http://services.samples", "m0"); OMElement placeOrder = factory.createOMElement("placeOrder", ns); OMElement order = factory.createOMElement("order", ns); OMElement price = factory.createOMElement("price", ns); OMElement quantity = factory.createOMElement("quantity", ns); OMElement symb = factory.createOMElement("symbol", ns); price.setText(Double.toString(purchasePrice)); quantity.setText(Integer.toString(qty)); symb.setText(symbol); order.addChild(price); order.addChild(quantity); order.addChild(symb); placeOrder.addChild(order); return placeOrder; }
Example 7
Source File: InvalidSoapActionTestCase.java From micro-integrator with Apache License 2.0 | 5 votes |
private OMElement createCustomQuoteRequest(String symbol) { OMFactory factory = OMAbstractFactory.getOMFactory(); OMNamespace ns = factory.createOMNamespace("http://services.samples", "ns"); OMElement chkPrice = factory.createOMElement("CheckPriceRequest", ns); OMElement code = factory.createOMElement("Code", ns); chkPrice.addChild(code); code.setText(symbol); return chkPrice; }
Example 8
Source File: ParameterUtil.java From micro-integrator with Apache License 2.0 | 5 votes |
/** * Create an Axis2 parameter based on key and value. * * @param name * @param value * @return Parameter * @throws AxisFault */ public static Parameter createParameter(String name, String value) throws AxisFault { OMFactory fac = OMAbstractFactory.getOMFactory(); OMNamespace ns = fac.createOMNamespace("", ""); OMElement paramEle = fac.createOMElement("parameter", ns); if (name == null) { throw new AxisFault("Parameter name is madatory."); } paramEle.addAttribute("name", name, ns); if (value != null && value.length() != 0) { paramEle.setText(value); } return createParameter(paramEle); }
Example 9
Source File: PolicyUtil.java From micro-integrator with Apache License 2.0 | 5 votes |
public static OMElement getWrapper(String name) { OMFactory fac = OMAbstractFactory.getOMFactory(); OMNamespace namespace = fac.createOMNamespace("", name); OMElement element = fac.createOMElement("Policy", namespace); OMAttribute attribute = fac.createOMAttribute("name", namespace, name); element.addAttribute(attribute); return element; }
Example 10
Source File: LoadbalanceFailoverClient.java From product-ei with Apache License 2.0 | 5 votes |
/** * This method is used to send a single request to the load balancing service which will invoke a sleep in the service * @param proxyURL will be the location where load balancing proxy or sequence is defined. * @param sleepTimeInMilliSeconds * @param clientTimeoutInMilliSeconds * @return * @throws org.apache.axis2.AxisFault */ public String sendSleepRequest(String proxyURL,String sleepTimeInMilliSeconds, String clientTimeoutInMilliSeconds) throws AxisFault { OMFactory fac = OMAbstractFactory.getOMFactory(); OMNamespace omNs = fac.createOMNamespace("http://services.samples", "ns"); OMElement sleepOperation = fac.createOMElement("sleepOperation", omNs); OMElement load = fac.createOMElement("load",null); load.setText(sleepTimeInMilliSeconds); sleepOperation.addChild(load); Options options = new Options(); if (proxyURL != null && !"null".equals(proxyURL)) { options.setTo(new EndpointReference(proxyURL)); } options.setAction("urn:sleepOperation"); long timeout = Integer.parseInt(getProperty("timeout", clientTimeoutInMilliSeconds)); System.out.println("timeout=" + timeout); options.setTimeOutInMilliSeconds(timeout); serviceClient.setOptions(options); serviceClient.getOptions().setManageSession(true); OMElement responseElement = serviceClient.sendReceive(sleepOperation); String response = responseElement.getText(); return response; }
Example 11
Source File: LoadbalanceFailoverClient.java From micro-integrator with Apache License 2.0 | 5 votes |
/** * This method is used to send a single request to the load balancing service * * @param proxyURL will be the location where load balancing proxy or sequence is defined. * @param serviceURL will be the URL for LBService * @return the response * @throws org.apache.axis2.AxisFault */ public String sendLoadBalanceRequest(String proxyURL, String serviceURL, String clientTimeoutInMilliSeconds) throws AxisFault { OMFactory fac = OMAbstractFactory.getOMFactory(); OMElement value = fac.createOMElement("Value", null); value.setText("Sample string"); Options options = new Options(); if (proxyURL != null && !"null".equals(proxyURL)) { options.setTo(new EndpointReference(proxyURL)); } options.setAction("urn:sampleOperation"); long timeout = Integer.parseInt(getProperty("timeout", clientTimeoutInMilliSeconds)); System.out.println("timeout=" + timeout); options.setTimeOutInMilliSeconds(timeout); if (serviceURL != null && !"null".equals(serviceURL)) { // set addressing, transport and proxy url serviceClient.engageModule("addressing"); options.setTo(new EndpointReference(serviceURL)); } serviceClient.setOptions(options); serviceClient.getOptions().setManageSession(true); OMElement responseElement = serviceClient.sendReceive(value); String response = responseElement.getText(); return response; }
Example 12
Source File: StockQuoteHandler.java From micro-integrator with Apache License 2.0 | 5 votes |
/** * Create a new full quote request with a body as follows * <m:GetFullQuote xmlns:m="http://services.samples"> * <m:request> * <m:symbol>IBM</m:symbol> * </m:request> * </m:GetFullQuote> * @param symbol the stock symbol * @return OMElement for SOAP body */ public static OMElement createFullQuoteRequest(String symbol) { OMFactory factory = OMAbstractFactory.getOMFactory(); OMNamespace ns = factory.createOMNamespace("http://services.samples", "m0"); OMElement getQuote = factory.createOMElement("getFullQuote", ns); OMElement request = factory.createOMElement("request", ns); OMElement symb = factory.createOMElement("symbol", ns); request.addChild(symb); getQuote.addChild(request); symb.setText(symbol); return getQuote; }
Example 13
Source File: EnrichIntegrationReplaceBodyWithInlineTestCase.java From product-ei with Apache License 2.0 | 5 votes |
private OMElement createFakeRequest(String symbol) { OMFactory fac = OMAbstractFactory.getOMFactory(); OMNamespace omNs = fac.createOMNamespace("http://services.samples", "ns"); OMElement method = fac.createOMElement("getQuoteRequest", omNs); OMElement value1 = fac.createOMElement("symbols", omNs); OMElement value2 = fac.createOMElement("symbol", omNs); value2.addChild(fac.createOMText(value1, symbol)); value1.addChild(value2); method.addChild(value1); return method; }
Example 14
Source File: AxisServiceClientUtils.java From product-ei with Apache License 2.0 | 5 votes |
private static OMElement createPayLoad() { OMFactory fac = OMAbstractFactory.getOMFactory(); OMNamespace omNs = fac.createOMNamespace("http://test.com", "test"); OMElement method = fac.createOMElement("add", omNs); OMElement valueOfa = fac.createOMElement("a", omNs); OMElement valueOfb = fac.createOMElement("b", omNs); valueOfa.addChild(fac.createOMText(valueOfa, "200")); valueOfb.addChild(fac.createOMText(valueOfb, "220")); method.addChild(valueOfa); method.addChild(valueOfb); return method; }
Example 15
Source File: StockQuoteClient.java From micro-integrator with Apache License 2.0 | 5 votes |
private OMElement createMultipleQuoteRequest(String symbol, int iterations) { OMFactory fac = OMAbstractFactory.getOMFactory(); OMNamespace omNs = fac.createOMNamespace("http://services.samples", "ns"); OMElement method = fac.createOMElement("getQuote", omNs); for (int i = 0; i < iterations; i++) { 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: ExcelDataServiceTestCase.java From micro-integrator with Apache License 2.0 | 5 votes |
@Test(groups = { "wso2.dss" }, invocationCount = 5) public void selectOperation() throws AxisFault, XPathExpressionException { OMFactory fac = OMAbstractFactory.getOMFactory(); OMNamespace omNs = fac.createOMNamespace("http://ws.wso2.org/dataservice", "ns1"); OMElement payload = fac.createOMElement("getProducts", omNs); OMElement result = new AxisServiceClient().sendReceive(payload, getServiceUrlHttp(serviceName), "getProducts"); log.info("Response :" + result); Assert.assertTrue((result.toString().indexOf("Products") == 1), "Expected Result Not found"); Assert.assertTrue(result.toString().contains("<Product>"), "Expected Result Not found"); Assert.assertTrue(result.toString().contains("<ID>"), "Expected Result Not found"); Assert.assertTrue(result.toString().contains("<Name>"), "Expected Result Not found"); log.info("Service invocation success"); }
Example 17
Source File: SqlRepairTest.java From openxds with Apache License 2.0 | 4 votes |
OMFactory om_factory() { if (om_factory == null) om_factory = OMAbstractFactory.getOMFactory(); return om_factory; }
Example 18
Source File: DataServiceFault.java From micro-integrator with Apache License 2.0 | 4 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) public static OMElement extractFaultMessage(Throwable throwable) { if (throwable instanceof DataServiceFault) { if (throwable.getCause() instanceof XMLStreamException) { return extractFaultMessage(((XMLStreamException) throwable.getCause()).getNestedException()); } OMFactory fac = OMAbstractFactory.getOMFactory(); OMElement root = fac.createOMElement(new QName( DBConstants.WSO2_DS_NAMESPACE, DBConstants.DS_FAULT_ELEMENT)); OMNamespace ns = root.getNamespace(); for (Map.Entry<String, Object> rootEntry : ((DataServiceFault) throwable).getPropertyMap().entrySet()) { OMElement keyElement = fac.createOMElement(rootEntry.getKey(), ns); if (rootEntry.getValue() instanceof Map) { for (Map.Entry dataServiceEntry : (Set<Map.Entry>) ((Map) rootEntry.getValue()).entrySet()) { OMElement dataServiceKeyElement = fac.createOMElement( dataServiceEntry.getKey().toString(), ns); OMText dataServiceValueElement = fac.createOMText( dataServiceKeyElement, dataServiceEntry.getValue().toString()); dataServiceKeyElement.addChild(dataServiceValueElement); keyElement.addChild(dataServiceKeyElement); } } else { OMText valueElement = fac.createOMText( keyElement, rootEntry.getValue().toString()); keyElement.addChild(valueElement); } root.addChild(keyElement); } return root; } else if (throwable instanceof XMLStreamException) { return extractFaultMessage(((XMLStreamException) throwable).getNestedException()); } else if (throwable != null) { Throwable cause = throwable.getCause(); if (cause != null) { return extractFaultMessage(cause); } else { return null; } } else { return null; } }
Example 19
Source File: SecureDataServiceTestCase.java From product-ei with Apache License 2.0 | 4 votes |
private OMElement getPayload() { OMFactory fac = OMAbstractFactory.getOMFactory(); OMNamespace omNs = fac.createOMNamespace("http://ws.wso2.org/dataservice/samples/secure_dataservice", "ns1"); return fac.createOMElement("showAllOffices", omNs); }
Example 20
Source File: FaultyDataServiceTestCase.java From micro-integrator with Apache License 2.0 | 4 votes |
private OMElement getPayload() { OMFactory fac = OMAbstractFactory.getOMFactory(); OMNamespace omNs = fac.createOMNamespace("http://ws.wso2.org/dataservice/samples/faulty_dataservice", "ns1"); return fac.createOMElement("showAllOffices", omNs); }