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


Java SOAPFactory.createSOAPEnvelope方法代码示例

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


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

示例1: buildSoapEnvelope

import org.apache.axiom.soap.SOAPFactory; //导入方法依赖的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.SOAPFactory; //导入方法依赖的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.SOAPFactory; //导入方法依赖的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: testSoapOMSerialization

import org.apache.axiom.soap.SOAPFactory; //导入方法依赖的package包/类
public void testSoapOMSerialization() throws Exception {
    TestLogger.logger.debug("---------------------------------------");
    TestLogger.logger.debug("test: " + getName());
    
    OMElement payload = createPayload();
    
    SOAPFactory factory = new SOAP11Factory();
    SOAPEnvelope env = factory.createSOAPEnvelope();
    SOAPBody body = factory.createSOAPBody(env);
    
    body.addChild(payload);
    
    OMOutputFormat format = new OMOutputFormat();
    format.setDoOptimize(true);
    format.setSOAP11(true);
           
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    env.serializeAndConsume(baos, format);

    TestLogger.logger.debug("==================================");
    TestLogger.logger.debug(baos.toString());
    TestLogger.logger.debug("==================================");
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:24,代码来源:MTOMSerializationTests.java

示例5: invoke

import org.apache.axiom.soap.SOAPFactory; //导入方法依赖的package包/类
public OMElement invoke(OMElement obj) {
    // since this is test code, let's check the inbound obj:
    SOAPEnvelope inboundEnv = (SOAPEnvelope)obj;
    SOAPBody inboundBody = inboundEnv.getBody();
    Iterator it = inboundBody.getChildren();
    OMElement el3 = null;
    for (;it.hasNext();) {
        OMElement el2 = (OMElement)it.next();
        Iterator it2 = el2.getChildElements();
        for (;it2.hasNext();) {
            el3 = (OMElement)it2.next();
            assert(el3.getText().equals("SAMPLE REQUEST MESSAGE"));
        }
    }
    assert(el3 != null);

    OMElement payload = createPayload();
    
    SOAPFactory factory = new SOAP12Factory();
    SOAPEnvelope env = factory.createSOAPEnvelope();
    SOAPBody body = factory.createSOAPBody(env);
    
    body.addChild(payload);
    
    return env;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:27,代码来源:OMElementProvider.java

示例6: testMessageBuilingFromByteArray

import org.apache.axiom.soap.SOAPFactory; //导入方法依赖的package包/类
public void testMessageBuilingFromByteArray() throws Exception {

        SOAPFactory fac = OMAbstractFactory.getSOAP12Factory();
        SOAPEnvelope env = fac.createSOAPEnvelope();
        fac.createSOAPBody(env);
        env.getBody().addChild(fac.createOMElement("test", "http://t", "t"));
        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
        try {
            env.serialize(outStream);
            MessageFactory mf = MessageFactory.newInstance();
            mf.createMessage(new MimeHeaders(), new ByteArrayInputStream(outStream.toByteArray()));
        } catch (Exception e) {
            e.printStackTrace();
            assertTrue(true);
        }
    }
 
开发者ID:wso2-attic,项目名称:carbon-qos,代码行数:17,代码来源:SAAJMessageBuilderTest.java

示例7: sendError

import org.apache.axiom.soap.SOAPFactory; //导入方法依赖的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

示例8: sendError

import org.apache.axiom.soap.SOAPFactory; //导入方法依赖的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

示例9: getMCWithSOAP11Envelope

import org.apache.axiom.soap.SOAPFactory; //导入方法依赖的package包/类
public static MessageContext getMCWithSOAP11Envelope() throws AxisFault {
    MessageContext messageContext = new MessageContext();
    SOAPFactory factory = new SOAP11Factory();
    SOAPEnvelope envelope = factory.createSOAPEnvelope();
    messageContext.setEnvelope(envelope);
    return messageContext;
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:8,代码来源:CommandBuilderTestUtils.java

示例10: getMCWithSOAP12Envelope

import org.apache.axiom.soap.SOAPFactory; //导入方法依赖的package包/类
public static MessageContext getMCWithSOAP12Envelope() throws AxisFault {
    MessageContext messageContext = new MessageContext();
    SOAPFactory factory = new SOAP12Factory();
    SOAPEnvelope envelope = factory.createSOAPEnvelope();
    messageContext.setEnvelope(envelope);
    return messageContext;
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:8,代码来源:CommandBuilderTestUtils.java

示例11: _createEmptyEnvelope

import org.apache.axiom.soap.SOAPFactory; //导入方法依赖的package包/类
/**
 * Create an emtpy envelope
 *
 * @param protocol
 * @param style
 * @param factory
 * @return
 */
private static SOAPEnvelope _createEmptyEnvelope(Style style, SOAPFactory factory) {
    SOAPEnvelope env = factory.createSOAPEnvelope();
    // Add an empty body and header
    factory.createSOAPBody(env);
    factory.createSOAPHeader(env);

    // Create a dummy operation element if this is an rpc message
    if (style == Style.RPC) {
        OMNamespace ns = factory.createOMNamespace("", "");
        factory.createOMElement("PLACEHOLDER_OPERATION", ns, env.getBody());
    }

    return env;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:23,代码来源:XMLSpineImpl.java

示例12: createAndSendSOAPResponse

import org.apache.axiom.soap.SOAPFactory; //导入方法依赖的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

示例13: createMessageContext

import org.apache.axiom.soap.SOAPFactory; //导入方法依赖的package包/类
private MessageContext createMessageContext(SOAPFactory soapFactory) {
    MessageContext messageContext = null;
    AxisService as1 = new AxisService("Service1");
    ConfigurationContext cc = null;
    try {
        cc = ConfigurationContextFactory.createEmptyConfigurationContext();
        AxisConfiguration ac = cc.getAxisConfiguration();
        ac.addService(as1);
        messageContext = cc.createMessageContext();
        messageContext.setAxisService(as1);

        SOAPEnvelope se = soapFactory.createSOAPEnvelope();

        SOAPHeader sh = soapFactory.createSOAPHeader(se);

        SOAPHeaderBlock shb1 = sh.addHeaderBlock(header_ultimateReceiver, 
                                                 omFactory.createOMNamespace(namespace, header_ultimateReceiver));
        // Since no role was set on the shb1, default is ultimate receiver
        shb1.setMustUnderstand(true);
        
        SOAPHeaderBlock shb2 = sh.addHeaderBlock(header_rolePlayed, 
                                                 omFactory.createOMNamespace(namespace, header_rolePlayed));
        shb2.setRole(rolePlayed1);
        shb2.setMustUnderstand(true);
        
        SOAPHeaderBlock shb3 = sh.addHeaderBlock(header_roleNotPlayed, 
                                                 omFactory.createOMNamespace(namespace, header_roleNotPlayed));
        shb3.setRole(roleNotPlayed);
        shb3.setMustUnderstand(true);
        
        SOAPHeaderBlock shb4 = sh.addHeaderBlock(header_bindingAdded,
                                                 omFactory.createOMNamespace(namespace, header_bindingAdded));
        shb4.setRole(roleBindingAdded);
        shb4.setMustUnderstand(true);
        
        // This header is destined for the ulmiate receiver, but it is already processed
        // so it shouldn't cause mustUnderstand fault
        SOAPHeaderBlock shb5 = sh.addHeaderBlock(header_ultimateReceiver_processed,
                                                 omFactory.createOMNamespace(namespace, header_ultimateReceiver_processed));
        // Since no role was set on the shb1, default is ultimate receiver
        shb5.setMustUnderstand(true);
        shb5.setProcessed();
        
        // Header targeted for SOAP11 role of Next, not set to MustUnderstand
        SOAPHeaderBlock shb6 = sh.addHeaderBlock(header_SoapNext,
                                                 omFactory.createOMNamespace(soap11Namespace, header_SoapNext));
        shb6.setRole(roleSoap11Next);

        messageContext.setEnvelope(se);
    } catch (AxisFault e) {
        fail("Caught unexpected exception creating message context" + e);
    }
    return messageContext;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:55,代码来源:RoleBasedMustUndertandTests.java


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