Java Code Examples for org.apache.axiom.soap.SOAPFactory#createOMElement()

The following examples show how to use org.apache.axiom.soap.SOAPFactory#createOMElement() . 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: LoadbalanceFailoverClient.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
private SOAPEnvelope buildSoapEnvelope(String clientID, String value) {
    SOAPFactory soapFactory = OMAbstractFactory.getSOAP12Factory();

    SOAPEnvelope envelope = soapFactory.createSOAPEnvelope();

    SOAPHeader header = soapFactory.createSOAPHeader();
    envelope.addChild(header);

    OMNamespace synNamespace = soapFactory.
            createOMNamespace("http://ws.apache.org/ns/synapse", "syn");
    OMElement clientIDElement = soapFactory.createOMElement("ClientID", synNamespace);
    clientIDElement.setText(clientID);
    header.addChild(clientIDElement);

    SOAPBody body = soapFactory.createSOAPBody();
    envelope.addChild(body);

    OMElement valueElement = soapFactory.createOMElement("Value", null);
    valueElement.setText(value);
    body.addChild(valueElement);

    return envelope;
}
 
Example 2
Source File: LoadbalanceFailoverClient.java    From product-ei with Apache License 2.0 6 votes vote down vote up
private SOAPEnvelope buildSoapEnvelope(String clientID, String value) {
    SOAPFactory soapFactory = OMAbstractFactory.getSOAP12Factory();

    SOAPEnvelope envelope = soapFactory.createSOAPEnvelope();

    SOAPHeader header = soapFactory.createSOAPHeader();
    envelope.addChild(header);

    OMNamespace synNamespace = soapFactory.
            createOMNamespace("http://ws.apache.org/ns/synapse", "syn");
    OMElement clientIDElement = soapFactory.createOMElement("ClientID", synNamespace);
    clientIDElement.setText(clientID);
    header.addChild(clientIDElement);

    SOAPBody body = soapFactory.createSOAPBody();
    envelope.addChild(body);

    OMElement valueElement = soapFactory.createOMElement("Value", null);
    valueElement.setText(value);
    body.addChild(valueElement);

    return envelope;
}
 
Example 3
Source File: AggregatedRequestClient.java    From micro-integrator with Apache License 2.0 6 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 method1 = fac.createOMElement("getQuotes", omNs);
    OMElement method2 = 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);
        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: LoadBalanceSessionFullClient.java    From product-ei with Apache License 2.0 6 votes vote down vote up
private SOAPEnvelope buildSoapEnvelope(String clientID, String value) {
    SOAPFactory soapFactory = OMAbstractFactory.getSOAP12Factory();

    SOAPEnvelope envelope = soapFactory.createSOAPEnvelope();

    SOAPHeader header = soapFactory.createSOAPHeader();
    envelope.addChild(header);

    OMNamespace synNamespace = soapFactory.createOMNamespace(
        "http://ws.apache.org/ns/synapse", "syn");
    OMElement clientIDElement = soapFactory.createOMElement("ClientID", synNamespace);
    clientIDElement.setText(clientID);
    header.addChild(clientIDElement);

    SOAPBody body = soapFactory.createSOAPBody();
    envelope.addChild(body);

    OMElement valueElement = soapFactory.createOMElement("Value", null);
    valueElement.setText(value);
    body.addChild(valueElement);

    return envelope;
}
 
Example 6
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 7
Source File: EnrichIntegrationBodyToSiblingOfBodyTestCase.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: CloneSOAPActionTestCase.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 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: 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 11
Source File: JMSReplySenderTest.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private void setSOAPEnvelopWithoutTypeTextMessageBody(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 firstEle = fac.createOMElement(new QName("First"));
    firstEle.addChild(mapElement1);
    env.getBody().addChild(firstEle);
    messageContext.setEnvelope(env);
}
 
Example 12
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 13
Source File: IterateSequentialPropertyTestCase.java    From product-ei 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 14
Source File: AggregatedRequestClient.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private OMElement createMultipleQuoteRequestBodynew(String symbol, int iterations) {
    SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
    OMNamespace omNs = fac.createOMNamespace("http://services.samples", "ns");
    OMElement method2 = 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);
        method2.addChild(value1);
    }
    return method2;
}
 
Example 15
Source File: IterateClient.java    From product-ei 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 16
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 17
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 18
Source File: MTOMSwAClient.java    From product-ei with Apache License 2.0 4 votes vote down vote up
public static MessageContext sendUsingSwA(String fileName, String targetEPR) throws IOException {

        Options options = new Options();
        options.setTo(new EndpointReference(targetEPR));
        options.setAction("urn:uploadFileUsingSwA");
        options.setProperty(Constants.Configuration.ENABLE_SWA, Constants.VALUE_TRUE);

        ServiceClient sender = createServiceClient();
        sender.setOptions(options);
        OperationClient mepClient = sender.createClient(ServiceClient.ANON_OUT_IN_OP);

        MessageContext mc = new MessageContext();

        System.out.println("Sending file : " + fileName + " as SwA");
        FileDataSource fileDataSource = new FileDataSource(new File(fileName));
        DataHandler dataHandler = new DataHandler(fileDataSource);
        String attachmentID = mc.addAttachment(dataHandler);


        SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
        SOAPEnvelope env = factory.getDefaultEnvelope();
        OMNamespace ns = factory.createOMNamespace("http://services.samples", "m0");
        OMElement payload = factory.createOMElement("uploadFileUsingSwA", ns);
        OMElement request = factory.createOMElement("request", ns);
        OMElement imageId = factory.createOMElement("imageId", ns);
        imageId.setText(attachmentID);
        request.addChild(imageId);
        payload.addChild(request);
        env.getBody().addChild(payload);
        mc.setEnvelope(env);

        mepClient.addMessageContext(mc);
        mepClient.execute(true);
        MessageContext response = mepClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);

        SOAPBody body = response.getEnvelope().getBody();
        String imageContentId = body.
                getFirstChildWithName(new QName("http://services.samples", "uploadFileUsingSwAResponse")).
                getFirstChildWithName(new QName("http://services.samples", "response")).
                getFirstChildWithName(new QName("http://services.samples", "imageId")).
                getText();

        Attachments attachment = response.getAttachmentMap();
        dataHandler = attachment.getDataHandler(imageContentId);
        File tempFile = File.createTempFile("swa-", ".gif");
        FileOutputStream fos = new FileOutputStream(tempFile);
        dataHandler.writeTo(fos);
        fos.flush();
        fos.close();

        System.out.println("Saved response to file : " + tempFile.getAbsolutePath());

        return response;
    }
 
Example 19
Source File: MTOMSwAClient.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
public static MessageContext sendUsingSwA(String fileName, String targetEPR) throws IOException {

        Options options = new Options();
        options.setTo(new EndpointReference(targetEPR));
        options.setAction("urn:uploadFileUsingSwA");
        options.setProperty(Constants.Configuration.ENABLE_SWA, Constants.VALUE_TRUE);

        ServiceClient sender = createServiceClient();
        sender.setOptions(options);
        OperationClient mepClient = sender.createClient(ServiceClient.ANON_OUT_IN_OP);

        MessageContext mc = new MessageContext();

        System.out.println("Sending file : " + fileName + " as SwA");
        FileDataSource fileDataSource = new FileDataSource(new File(fileName));
        DataHandler dataHandler = new DataHandler(fileDataSource);
        String attachmentID = mc.addAttachment(dataHandler);


        SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
        SOAPEnvelope env = factory.getDefaultEnvelope();
        OMNamespace ns = factory.createOMNamespace("http://services.samples", "m0");
        OMElement payload = factory.createOMElement("uploadFileUsingSwA", ns);
        OMElement request = factory.createOMElement("request", ns);
        OMElement imageId = factory.createOMElement("imageId", ns);
        imageId.setText(attachmentID);
        request.addChild(imageId);
        payload.addChild(request);
        env.getBody().addChild(payload);
        mc.setEnvelope(env);

        mepClient.addMessageContext(mc);
        mepClient.execute(true);
        MessageContext response = mepClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);

        SOAPBody body = response.getEnvelope().getBody();
        String imageContentId = body.
                getFirstChildWithName(new QName("http://services.samples", "uploadFileUsingSwAResponse")).
                getFirstChildWithName(new QName("http://services.samples", "response")).
                getFirstChildWithName(new QName("http://services.samples", "imageId")).
                getText();

        Attachments attachment = response.getAttachmentMap();
        dataHandler = attachment.getDataHandler(imageContentId);
        File tempFile = File.createTempFile("swa-", ".gif");
        FileOutputStream fos = new FileOutputStream(tempFile);
        dataHandler.writeTo(fos);
        fos.flush();
        fos.close();

        System.out.println("Saved response to file : " + tempFile.getAbsolutePath());

        return response;
    }
 
Example 20
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;
    }