当前位置: 首页>>代码示例>>Java>>正文


Java SOAPEnvelope.addChild方法代码示例

本文整理汇总了Java中org.apache.axiom.soap.SOAPEnvelope.addChild方法的典型用法代码示例。如果您正苦于以下问题:Java SOAPEnvelope.addChild方法的具体用法?Java SOAPEnvelope.addChild怎么用?Java SOAPEnvelope.addChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.axiom.soap.SOAPEnvelope的用法示例。


在下文中一共展示了SOAPEnvelope.addChild方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildSoapEnvelope

import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
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;
}
 
开发者ID:wso2,项目名称:product-ei,代码行数:24,代码来源:LoadBalanceSessionFullClient.java

示例2: buildSoapEnvelope

import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
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;
}
 
开发者ID:wso2,项目名称:product-ei,代码行数:24,代码来源:LoadbalanceFailoverClient.java

示例3: sendSOAPResponse

import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
public static String sendSOAPResponse(HttpServletResponse response, OMElement resultElements) {
    
    try {
        SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory();
        SOAPEnvelope responseEnvelope = soapFactory.createSOAPEnvelope();
        SOAPBody responseBody = soapFactory.createSOAPBody();
        responseBody.addChild(resultElements);
        responseEnvelope.addChild(responseBody);
        // log the response message
        if (Debug.infoOn()) {
            Debug.logInfo("SOAP Response Message:\n" + responseEnvelope + "\n", module);
        }
        response.setContentType(SoapService.XML_TYPE);
        OutputStream out = response.getOutputStream();
        responseEnvelope.serialize(out);
        out.flush();
    }
    catch (Exception ex) {
        Debug.logError("Error invoking soap service " + ex.getMessage(), module);
        return "error";
    }
    return "success";
}
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:24,代码来源:SOAPEventHandlerNew.java

示例4: sendError

import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
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 = new StAXOMBuilder(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);
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:40,代码来源:SOAPEventHandler.java

示例5: sendError

import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
private void sendError(HttpServletResponse res, Map<String, Object> object, String serviceName) throws EventHandlerException {
    try {
        // setup the response
        SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
        res.setContentType("text/xml");
        OMElement resultSer = SoapService.serializeParamsToXML(
                factory.createOMElement(serviceName + "Response", 
                        factory.createOMNamespace(ModelService.TNS, "tns")), object);

        // create the response soap
        SOAPEnvelope resEnv = factory.createSOAPEnvelope();
        SOAPBody resBody = factory.createSOAPBody();
        resBody.addChild(resultSer);
        resEnv.addChild(resBody);

        // 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);
    }
}
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:30,代码来源:SOAPEventHandlerNew.java

示例6: createAndSendSOAPResponse

import org.apache.axiom.soap.SOAPEnvelope; //导入方法依赖的package包/类
private void createAndSendSOAPResponse(Map<String, Object> serviceResults, String serviceName, HttpServletResponse response) throws EventHandlerException {
    try {
    // setup the response
        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 = new StAXOMBuilder(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);
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:42,代码来源:SOAPEventHandler.java


注:本文中的org.apache.axiom.soap.SOAPEnvelope.addChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。