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


Java SOAPFactory.getDefaultEnvelope方法代码示例

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


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

示例1: createDefaultSOAPEnvelope

import org.apache.axiom.soap.SOAPFactory; //导入方法依赖的package包/类
private SOAPEnvelope createDefaultSOAPEnvelope(MessageContext inMsgCtx) {

        String soapNamespace = inMsgCtx.getEnvelope().getNamespace()
                .getNamespaceURI();
        SOAPFactory soapFactory = null;
        if (soapNamespace.equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
            soapFactory = OMAbstractFactory.getSOAP11Factory();
        } else if (soapNamespace
                .equals(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
            soapFactory = OMAbstractFactory.getSOAP12Factory();
        } else {
            log.error("Unknown SOAP Envelope");
        }
        if (soapFactory != null) {
            return soapFactory.getDefaultEnvelope();
        }

        return null;
    }
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:20,代码来源:WSXACMLMessageReceiver.java

示例2: invokeBusinessLogic

import org.apache.axiom.soap.SOAPFactory; //导入方法依赖的package包/类
/**
 * this is the method invoke by the axis2 engine
 * @param inMessageContext   - input message context from which we can get the in comming OMElement
 * @param outMessageContext  - output message context to which we can set the out going soap message.
 * @throws AxisFault  - throws if some problem happens with the processing.
 */
public void invokeBusinessLogic(MessageContext inMessageContext,
                                MessageContext outMessageContext) throws AxisFault {
    OMElement inputOMElement = inMessageContext.getEnvelope().getBody().getFirstElement();

    SOAPFactory soapFactory = getSOAPFactory(inMessageContext);
    SOAPEnvelope soapEnvelope = soapFactory.getDefaultEnvelope();
    RuleSession ruleSession;
    try {
        ruleSession = getRuleSession(inMessageContext);
        soapEnvelope.getBody().addChild(ruleSession.execute(inputOMElement, this.input, this.output));
        outMessageContext.setEnvelope(soapEnvelope);
    } catch (RuleRuntimeException e) {
        log.error("Can not create the rule session", e);
        throw new AxisFault("Can not create the rule session", e);
    }

}
 
开发者ID:wso2,项目名称:carbon-rules,代码行数:24,代码来源:RuleMessageReceiver.java

示例3: createMessageContext

import org.apache.axiom.soap.SOAPFactory; //导入方法依赖的package包/类
public static MessageContext createMessageContext(OMElement payload,
                                                  OMElement topic,
                                                  int tenantId) throws EventBrokerException {
    MessageContext mc = new MessageContext();
    mc.setConfigurationContext(new ConfigurationContext(new AxisConfiguration()));
    PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenantId);
    SOAPFactory soapFactory = new SOAP12Factory();
    SOAPEnvelope envelope = soapFactory.getDefaultEnvelope();
    envelope.getBody().addChild(payload);
    if (topic != null) {
        envelope.getHeader().addChild(topic);
    }
    try {
        mc.setEnvelope(envelope);
    } catch (Exception e) {

        throw new EventBrokerException("Unable to generate event.", e);
    }
    return mc;
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:21,代码来源:EventBrokerUtils.java

示例4: getAbstractResponseMessageContext

import org.apache.axiom.soap.SOAPFactory; //导入方法依赖的package包/类
public MessageContext getAbstractResponseMessageContext(MessageContext requestMessageContext) throws AxisFault {
    MessageContext outMessageCtx = MessageContextBuilder.createOutMessageContext(requestMessageContext);

    SOAPFactory factory = getSOAPFactory(requestMessageContext);
    AxisOperation operation = requestMessageContext.getOperationContext().getAxisOperation();
    AxisService service = requestMessageContext.getAxisService();

    OMElement bodyContent;
    AxisMessage outMessage = operation.getMessage(OperationsConstants.OUT);

    bodyContent = factory.createOMElement(outMessage.getName(),
            factory.createOMNamespace(namespace,
                    service.getSchemaTargetNamespacePrefix()));
    try {
        setPayload(bodyContent);
    } catch (XMLStreamException e) {
        String msg = "Error in adding the payload to the response message";
        log.error(msg);
        throw new AxisFault(msg, e);
    }

    SOAPEnvelope soapEnvelope = factory.getDefaultEnvelope();
    soapEnvelope.getBody().addChild(bodyContent);
    outMessageCtx.setEnvelope(soapEnvelope);
    return outMessageCtx;
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:27,代码来源:AbstractOperation.java

示例5: createElementMessageContextElement

import org.apache.axiom.soap.SOAPFactory; //导入方法依赖的package包/类
private MessageContext createElementMessageContextElement(String textPayload) throws AxisFault {

        try {
            MessageContext messageContext = new MessageContext();
            SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
            SOAPEnvelope envelope = factory.getDefaultEnvelope();
            OMElement textWrapper = factory.createOMElement(BaseConstants.DEFAULT_TEXT_WRAPPER);
            OMElement payload = AXIOMUtil.stringToOM(textPayload);
            textWrapper.addChild(payload);
            envelope.getBody().addChild(textWrapper);
            messageContext.setEnvelope(envelope);
            return messageContext;
        } catch (XMLStreamException e) {
            // This is highly unlikely to happen
            return null;
        }
    }
 
开发者ID:wso2,项目名称:wso2-axis2-transports,代码行数:18,代码来源:PlainTextFormatterTest.java

示例6: processDocument

import org.apache.axiom.soap.SOAPFactory; //导入方法依赖的package包/类
public OMElement processDocument(InputStream inputStream, String s, MessageContext messageContext) throws AxisFault {
    messageContext.setProperty(JsonConstant.IS_JSON_STREAM , true);
    JsonReader jsonReader;
    String charSetEncoding=null;
    if (inputStream != null) {
        try {
            charSetEncoding = (String) messageContext.getProperty(Constants.Configuration.CHARACTER_SET_ENCODING);
            jsonReader = new JsonReader(new InputStreamReader(inputStream, charSetEncoding));
            GsonXMLStreamReader gsonXMLStreamReader = new GsonXMLStreamReader(jsonReader);
            messageContext.setProperty(JsonConstant.GSON_XML_STREAM_READER, gsonXMLStreamReader);
        } catch (UnsupportedEncodingException e) {
            throw new AxisFault(charSetEncoding + " encoding is may not supported by json inputStream ", e);
        }
    } else {
        if (log.isDebugEnabled()) {
            log.debug("Inputstream is null, This is possible with GET request");
        }
    }
    // dummy envelop
    SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory();
    return soapFactory.getDefaultEnvelope();
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:23,代码来源:JsonBuilder.java

示例7: encode

import org.apache.axiom.soap.SOAPFactory; //导入方法依赖的package包/类
public AxisMessage encode(ClientOptions options, XMLMessage message) throws Exception {
    XMLMessage.Type type = message.getType();
    AxisMessage result = new AxisMessage();
    SOAPFactory factory;
    if (type == XMLMessage.Type.SOAP12 || type == XMLMessage.Type.SWA) {
        factory = OMAbstractFactory.getSOAP12Factory();
    } else {
        factory = OMAbstractFactory.getSOAP11Factory();
    }
    result.setMessageType(type.getContentType().toString());
    SOAPEnvelope envelope = factory.getDefaultEnvelope();
    envelope.getBody().addChild(message.getPayload());
    result.setEnvelope(envelope);
    if (type == XMLMessage.Type.SWA) {
        result.setAttachments(message.getAttachments());
    }
    return result;
}
 
开发者ID:wso2,项目名称:wso2-axis2-transports,代码行数:19,代码来源:MessageEncoder.java

示例8: testPopulate2

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

        XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(xmlString.getBytes()));
        XMLStreamReader reader2 = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(xmlString2.getBytes()));

        SOAPFactory soap11Factory = OMAbstractFactory.getSOAP11Factory();

        SOAPEnvelope defaultEnvelope = soap11Factory.getDefaultEnvelope();
        OMElement documentElement = new StAXOMBuilder(reader).getDocumentElement();
        defaultEnvelope.getBody().addChild(documentElement);

        OMElement documentElement2 = new StAXOMBuilder(reader2).getDocumentElement();
        defaultEnvelope.getHeader().addChild(documentElement2);

        XMLStreamReader xmlStreamReader = defaultEnvelope.getBody().getFirstElement().getXMLStreamReader();
        while(xmlStreamReader.hasNext()){
            System.out.println("event " + xmlStreamReader.next());
            System.out.println("text " +  (xmlStreamReader.hasText()?xmlStreamReader.getText():""));
            System.out.println("localName " + (xmlStreamReader.hasName()?xmlStreamReader.getLocalName():""));
        }
    }
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:22,代码来源:ADBInOutTest.java

示例9: testEchoXMLSyncMC

import org.apache.axiom.soap.SOAPFactory; //导入方法依赖的package包/类
public void testEchoXMLSyncMC() throws Exception {        
    AxisOperation opdesc = new OutInAxisOperation(new QName("echoOMElement"));
    Options options = new Options();
    options.setTo(targetEPR);
    options.setAction(operationName.getLocalPart());
    options.setTransportInProtocol(Constants.TRANSPORT_TCP);

    OMFactory fac = OMAbstractFactory.getOMFactory();

    OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
    OMElement method = fac.createOMElement("echoOMElement", omNs);
    OMElement value = fac.createOMElement("myValue", omNs);
    value.setText("Isaac Asimov, The Foundation Trilogy");
    method.addChild(value);
    SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
    SOAPEnvelope envelope = factory.getDefaultEnvelope();
    envelope.getBody().addChild(method);

    MessageContext requestContext = new MessageContext();
    requestContext.setConfigurationContext(configContext);
    requestContext.setAxisService(clientService);
    requestContext.setAxisOperation(opdesc);
    requestContext.setEnvelope(envelope);

    ServiceClient sender = new ServiceClient(configContext, clientService);
    sender.setOptions(options);
    OperationClient opClient = sender.createClient(new QName("echoOMElement"));
    opClient.addMessageContext(requestContext);
    opClient.setOptions(options);
    opClient.execute(true);

    MessageContext response = opClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
    SOAPEnvelope env = response.getEnvelope();
    assertNotNull(env);
    env.getBody().serialize(StAXUtils.createXMLStreamWriter(
            System.out));
    sender.cleanup();
}
 
开发者ID:wso2,项目名称:wso2-axis2-transports,代码行数:39,代码来源:TCPEchoRawXMLTest.java

示例10: getMessageElement

import org.apache.axiom.soap.SOAPFactory; //导入方法依赖的package包/类
public OMElement getMessageElement() {
    if (type == Type.POX) {
        return payload;
    } else {
        SOAPFactory factory;
        if (type == Type.SOAP11) {
            factory = OMAbstractFactory.getSOAP11Factory();
        } else {
            factory = OMAbstractFactory.getSOAP12Factory();
        }
        SOAPEnvelope envelope = factory.getDefaultEnvelope();
        envelope.getBody().addChild(payload);
        return envelope;
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2-transports,代码行数:16,代码来源:XMLMessage.java

示例11: testFileDataFields

import org.apache.axiom.soap.SOAPFactory; //导入方法依赖的package包/类
public void testFileDataFields() throws Exception {
    MultipartFormDataFormatter formatter = new MultipartFormDataFormatter();
    MessageContext mc = new MessageContext();
    SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
    SOAPEnvelope defaultEnvelope = factory.getDefaultEnvelope();
    /*
          <root xmlns="">
              <customFieldOne>$1</customFieldOne>
              <customFieldTwo>$2</customFieldTwo>
              <file xmlns="http://ws.apache.org/ns/synapse/form-data"
                    name="fieldname"
                    filename="sample-file.txt"
                    content-type="text/plain"
                    charset="US-ASCII">$3</file>
           </root>
     */

    OMElement rootElement = factory.createOMElement("root", null);
    OMElement customFieldOne = factory.createOMElement("customFieldOne", null);
    customFieldOne.setText("ValueOne");
    rootElement.addChild(customFieldOne);
    OMElement customFieldTwo = factory.createOMElement("customFieldTwo", null);
    customFieldTwo.setText("ValueTwo");
    rootElement.addChild(customFieldTwo);
    OMElement fileElement = factory.createOMElement("file", factory.createOMNamespace("http://org.apache.axis2/xsd/form-data",
                                                                               null));
    fileElement.addAttribute("filename", "sample-file.txt", null);
    fileElement.addAttribute("content-type", "application/xml", null);
    fileElement.addAttribute("charset", "UTF-8", null);
    String fileContent = "<Test content/>";
    fileElement.setText(new String(Base64.encodeBase64(fileContent.getBytes())));

    rootElement.addChild(fileElement);
    defaultEnvelope.getBody().addChild(rootElement);

    mc.setEnvelope(defaultEnvelope);

    OMOutputFormat format = new OMOutputFormat();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    formatter.writeTo(mc, format, baos, true);

    MimeMultipart mp = new MimeMultipart(new ByteArrayDataSource(baos.toByteArray(), format.getContentType()));

    assertEquals(3, mp.getCount());
    BodyPart bodyPartOne = mp.getBodyPart(0);
    assertEquals(null, bodyPartOne.getFileName());

    BodyPart bodyPartThree = mp.getBodyPart(2);
    assertEquals("application/xml; charset=UTF-8", bodyPartThree.getContentType());
    assertEquals("sample-file.txt", bodyPartThree.getFileName());

    ByteArrayInputStream contentStream = (ByteArrayInputStream) bodyPartThree.getContent();
    int n = contentStream.available();
    byte[] bytes = new byte[n];
    contentStream.read(bytes, 0, n);
    String content = new String((bytes));

    assertEquals(fileContent, content);
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:60,代码来源:MultipartFormDataFormatterTest.java

示例12: createEnvelope

import org.apache.axiom.soap.SOAPFactory; //导入方法依赖的package包/类
protected SOAPEnvelope createEnvelope() throws Exception {
    SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
    SOAPEnvelope env = fac.getDefaultEnvelope();

    OMNamespace omNs = fac.createOMNamespace("htp://localhost/my", "my");
    OMElement rpcWrapEle = fac.createOMElement("echoOMElement", omNs);
    OMElement data = fac.createOMElement("data", omNs);
    OMText textData = fac.createOMText("Apache Axis2 Rocks !!!");
    data.addChild(textData);
    rpcWrapEle.addChild(data);

    env.getBody().addChild(rpcWrapEle);
    return env;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:15,代码来源:EchoRawSwATest.java

示例13: testMulitref1

import org.apache.axiom.soap.SOAPFactory; //导入方法依赖的package包/类
public void testMulitref1() throws AxisFault {
    RPCServiceClient sender = getRPCClient("EchoXMLService", "echoString");
    OMFactory fac = OMAbstractFactory.getOMFactory();

    OMNamespace omNs = fac.createOMNamespace(NAMESPACE, "my");
    OMElement method = fac.createOMElement("echoString", omNs);
    OMElement value = fac.createOMElement("arg0", null);
    value.addAttribute(fac.createOMAttribute("href", null, "#1"));
    method.addChild(value);
    SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
    SOAPEnvelope envelope = factory.getDefaultEnvelope();
    envelope.getBody().addChild(method);

    OMElement ref = fac.createOMElement("reference", null);
    ref.addAttribute(fac.createOMAttribute("id", null, "1"));
    ref.setText("hello Axis2");
    envelope.getBody().addChild(ref);

    MessageContext reqMessageContext = new MessageContext();
    OperationClient opClinet = sender.createClient(ServiceClient.ANON_OUT_IN_OP);
  
    reqMessageContext.setEnvelope(envelope);

    opClinet.addMessageContext(reqMessageContext);
    opClinet.execute(true);

    MessageContext responseMessageContx =
            opClinet.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);

    SOAPEnvelope env = responseMessageContx.getEnvelope();


    assertEquals(env.getBody().getFirstElement().getFirstElement().getText(), "hello Axis2");
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:35,代码来源:MultirefTest.java

示例14: testaddSameRef

import org.apache.axiom.soap.SOAPFactory; //导入方法依赖的package包/类
public void testaddSameRef() throws AxisFault {
    RPCServiceClient sender = getRPCClient("EchoXMLService", "add");
    OMFactory fac = OMAbstractFactory.getOMFactory();

    OMNamespace omNs = fac.createOMNamespace(NAMESPACE, "my");
    OMElement method = fac.createOMElement("add", omNs);
    OMElement value = fac.createOMElement("arg0", null);
    value.addAttribute(fac.createOMAttribute("href", null, "#1"));
    method.addChild(value);

    OMElement value2 = fac.createOMElement("arg1", null);
    value2.addAttribute(fac.createOMAttribute("href", null, "#1"));
    method.addChild(value2);

    SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
    SOAPEnvelope envelope = factory.getDefaultEnvelope();
    envelope.getBody().addChild(method);

    OMElement ref = fac.createOMElement("reference", null);
    ref.addAttribute(fac.createOMAttribute("id", null, "1"));
    ref.setText("10");
    envelope.getBody().addChild(ref);

    MessageContext reqMessageContext = new MessageContext();
    OperationClient opClinet = sender.createClient(ServiceClient.ANON_OUT_IN_OP);
    
    reqMessageContext.setEnvelope(envelope);

    opClinet.addMessageContext(reqMessageContext);
    opClinet.execute(true);

    MessageContext responseMessageContx =
            opClinet.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
    SOAPEnvelope env = responseMessageContx.getEnvelope();

    assertEquals(env.getBody().getFirstElement().getFirstElement().getText(), "20");
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:38,代码来源:MultirefTest.java

示例15: testDuplicateHeaders

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

        // this will check whether we can add to epr, if there is one already.
        EndpointReference eprOne = new EndpointReference("http://whatever.org");
        EndpointReference duplicateEpr = new EndpointReference("http://whatever.duplicate.org");
        RelatesTo reply = new RelatesTo("urn:id");
        ConfigurationContext cfgCtx =
                ConfigurationContextFactory.createEmptyConfigurationContext();
        msgCtxt = cfgCtx.createMessageContext();
        SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
        SOAPEnvelope defaultEnvelope = factory.getDefaultEnvelope();
        msgCtxt.setEnvelope(defaultEnvelope);

        msgCtxt.addRelatesTo(reply);
        msgCtxt.setTo(eprOne);
        msgCtxt.setWSAAction("http://www.actions.org/action");
        outHandler.invoke(msgCtxt);

        // now the soap message within the msgCtxt must have a to header.
        // lets invoke twice and see
        msgCtxt.setTo(duplicateEpr);
        outHandler.invoke(msgCtxt);

        assertEquals("http://whatever.org", defaultEnvelope.getHeader()
                .getFirstChildWithName(Final.QNAME_WSA_TO).getText());
        Iterator iterator =
                defaultEnvelope.getHeader().getChildrenWithName(Final.QNAME_WSA_RELATES_TO);
        int i = 0;
        while (iterator.hasNext()) {
            iterator.next();
            i++;
        }
        assertEquals("Reply should be added twice.", 2, i);
    }
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:35,代码来源:AddressingOutHandlerTest.java


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