Java Code Examples for org.apache.axiom.om.OMAbstractFactory#getSOAP11Factory()

The following examples show how to use org.apache.axiom.om.OMAbstractFactory#getSOAP11Factory() . 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: IterateClient.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
private OMElement createGetQuotesRequestBody(String symbol, int iterations) {
    SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
    OMNamespace omNs = fac.createOMNamespace("http://services.samples", "ns");
    OMElement top = fac.createOMElement("getQuotes", omNs);

    for (int i = 0; i < iterations; i++) {
        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);
        top.addChild(method);
    }

    return top;
}
 
Example 2
Source File: IterateClient.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
private OMElement createGetQuotesRequestBody(String symbol, int iterations) {
    SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
    OMNamespace omNs = fac.createOMNamespace("http://services.samples", "ns");
    OMElement top = fac.createOMElement("getQuotes", omNs);

    for (int i = 0; i < iterations; i++) {
        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);
        top.addChild(method);
    }

    return top;
}
 
Example 3
Source File: NestedAggregatesTestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
private OMElement createNestedQuoteRequestBody(String symbol, int noOfItr) {
    SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
    OMNamespace omNs = fac.createOMNamespace("http://services.samples", "ns");
    OMElement method1 = fac.createOMElement("getQuotes", omNs);
    for (int i = 0; i < noOfItr; i++) {
        OMElement method2 = fac.createOMElement("getQuote", omNs);

        for (int j = 0; j < noOfItr; j++) {
            OMElement value1 = fac.createOMElement("request", omNs);
            OMElement value2 = fac.createOMElement("symbol", omNs);
            value2.addChild(fac.createOMText(value1, symbol));
            value1.addChild(value2);
            method2.addChild(value1);

        }
        method1.addChild(method2);
    }
    return method1;
}
 
Example 4
Source File: IterateClient.java    From product-ei with Apache License 2.0 6 votes vote down vote up
private OMElement createGetQuotesRequestBody(String symbol, int iterations) {
    SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
    OMNamespace omNs = fac.createOMNamespace("http://services.samples", "ns");
    OMElement top = fac.createOMElement("getQuotes", omNs);

    for (int i = 0; i < iterations; i++) {
        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);
        top.addChild(method);
    }

    return top;
}
 
Example 5
Source File: JMSReplySenderTest.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private void setSOAPEnvelopWithMapMessageBody(MessageContext messageContext) throws AxisFault, XMLStreamException {
    SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
    SOAPEnvelope env = fac.createSOAPEnvelope();
    fac.createSOAPBody(env);
    OMElement mapElement1 = fac.createOMElement(new QName("Price"));
    mapElement1.setText("10");
    OMElement mapElement2 = fac.createOMElement(new QName("Name"));
    mapElement2.setText("Queue");
    OMElement firstEle = fac.createOMElement(JMSConstants.JMS_MAP_QNAME);
    firstEle.addChild(mapElement1);
    firstEle.addChild(mapElement2);
    env.getBody().addChild(firstEle);
    messageContext.setEnvelope(env);
}
 
Example 6
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 7
Source File: IterateClient.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private OMElement createMultipleQuoteRequestBody(String symbol, int iterations) {
    SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
    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 8
Source File: IterateClient.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private OMElement createMultipleCustomQuoteRequestBody(String symbol, int iterations) {
    SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
    OMNamespace omNs = fac.createOMNamespace("http://services.samples", "ns");
    OMElement method = fac.createOMElement("getQuote", omNs);

    for (int i = 0; i < iterations; i++) {
        OMElement chkPrice = fac.createOMElement("CheckPriceRequest", omNs);
        OMElement code = fac.createOMElement("Code", omNs);
        chkPrice.addChild(code);
        code.setText(symbol);
        method.addChild(chkPrice);
    }
    return method;
}
 
Example 9
Source File: IterateSequentialPropertyTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private OMElement createMultipleQuoteRequestBody(String symbol, int iterations) {
    SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
    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 + "-" + i));
        value1.addChild(value2);
        method.addChild(value1);
    }
    return method;
}
 
Example 10
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 11
Source File: JMSReplySenderTest.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private void setSOAPEnvelopWithoutTypeByteMessageBody(MessageContext messageContext, BytesMessage message)
        throws AxisFault {
    SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
    SOAPEnvelope env = fac.createSOAPEnvelope();
    fac.createSOAPBody(env);
    OMElement firstEle = fac.createOMElement(new QName("Binary"));
    DataHandler dataHandler = new DataHandler(new BytesMessageDataSource(message));
    OMText textEle = fac.createOMText(dataHandler, true);
    firstEle.addChild(textEle);
    env.getBody().addChild(firstEle);
    messageContext.setEnvelope(env);
}
 
Example 12
Source File: IterateClient.java    From product-ei 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 13
Source File: ForEachSequentialExecutionTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private OMElement createMultipleSymbolPayLoad(int iterations) {
    SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
    OMNamespace omNs = fac.createOMNamespace("http://services.samples", "ns");
    OMElement method = fac.createOMElement("getQuote", omNs);

    for (int i = 0; i < iterations; i++) {
        OMElement chkPrice = fac.createOMElement("CheckPriceRequest", omNs);
        OMElement code = fac.createOMElement("Code", omNs);
        chkPrice.addChild(code);
        code.setText("SYM" + i);
        method.addChild(chkPrice);
    }
    return method;
}
 
Example 14
Source File: InboundWebsocketSourceHandler.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private static org.apache.synapse.MessageContext createSynapseMessageContext(String tenantDomain) throws AxisFault {
    org.apache.axis2.context.MessageContext axis2MsgCtx = createAxis2MessageContext();
    ServiceContext svcCtx = new ServiceContext();
    OperationContext opCtx = new OperationContext(new InOutAxisOperation(), svcCtx);
    axis2MsgCtx.setServiceContext(svcCtx);
    axis2MsgCtx.setOperationContext(opCtx);

    axis2MsgCtx.setProperty(TENANT_DOMAIN, SUPER_TENANT_DOMAIN_NAME);

    SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
    SOAPEnvelope envelope = fac.getDefaultEnvelope();
    axis2MsgCtx.setEnvelope(envelope);
    return MessageContextCreatorForAxis2.getSynapseMessageContext(axis2MsgCtx);
}
 
Example 15
Source File: CloneClient.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: AxisOperationClient.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * @param payload
 * @return
 */

private SOAPEnvelope createSOAPEnvelope(OMElement payload) {
    fac = OMAbstractFactory.getSOAP11Factory();
    envelope = fac.getDefaultEnvelope();
    envelope.getBody().addChild(payload);
    return envelope;
}
 
Example 17
Source File: SOAPEventHandler.java    From scipio-erp with Apache License 2.0 4 votes vote down vote up
private void createAndSendSOAPResponse(Map<String, Object> serviceResults, String serviceName, HttpServletResponse response) throws EventHandlerException {
    try {
    // setup the response
        if (Debug.verboseOn()) 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 = (StAXOMBuilder) OMXMLBuilderFactory.createStAXOMBuilder(OMAbstractFactory.getOMFactory(), 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);
    }
}
 
Example 18
Source File: PayloadFormatWithArgumentsTestCase.java    From micro-integrator 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 19
Source File: PayloadFormatWithNoArgumentTestCase.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 getOperation = fac.createOMElement("echoString", omNs);
        OMElement getName = fac.createOMElement("s", omNs);

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

        return getOperation;
    }
 
Example 20
Source File: AxisOperationClient.java    From product-ei with Apache License 2.0 3 votes vote down vote up
/**
 * Create the soap envelop
 *
 * @param symbol
 * @param iterations
 * @return
 */
private SOAPEnvelope createSOAPEnvelope(String symbol, int iterations) {
    fac = OMAbstractFactory.getSOAP11Factory();
    envelope = fac.getDefaultEnvelope();
    envelope.getBody().addChild(createMultipleQuoteRequestBody(symbol, iterations));
    return envelope;
}