Java Code Examples for org.apache.axiom.soap.SOAPEnvelope#addChild()

The following examples show how to use org.apache.axiom.soap.SOAPEnvelope#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: LoadBalanceSessionFullClient.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 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 3
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 4
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 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: 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 7
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 8
Source File: SOAPEventHandler.java    From scipio-erp with Apache License 2.0 5 votes vote down vote up
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 = (StAXOMBuilder) OMXMLBuilderFactory.createStAXOMBuilder(OMAbstractFactory.getOMFactory(), 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);
    }
}
 
Example 9
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);
    }
}