Package org.apache.axis2.om

Examples of org.apache.axis2.om.OMElement


  public static void printResult (SOAPEnvelope result) {
    try {
      XMLStreamWriter writer = XMLOutputFactory.newInstance()
          .createXMLStreamWriter(System.out);
      if (result != null){
        OMElement resultOM = result.getBody().getFirstChildWithName(new QName ("result"));
        System.out.println ("Result is:" + resultOM.getText());
      }else
        System.out.println("Result is null");
    } catch (XMLStreamException e) {
      e.printStackTrace();
    } catch (FactoryConfigurationError e) {
View Full Code Here


    SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
    SOAPEnvelope envelope = fac.getDefaultEnvelope();
    OMNamespace namespace = fac.createOMNamespace(
        "http://axis2/test/namespace1", "ns1");

    OMElement params = fac.createOMElement(operationName, namespace);
    OMElement param1OM = fac.createOMElement("param1", namespace);
    OMElement param2OM = fac.createOMElement("param2", namespace);
    param1OM.setText(Integer.toString(param1));
    param2OM.setText(Integer.toString(param2));
    params.addChild(param1OM);
    params.addChild(param2OM);
    envelope.getBody().setFirstChild(params);

    if (groupContextId != null) {
View Full Code Here

    SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
    SOAPEnvelope envelope = fac.getDefaultEnvelope();
    OMNamespace namespace = fac.createOMNamespace(
        "http://axis2/test/namespace1", "ns1");

    OMElement params = fac.createOMElement(operationName, namespace);
    OMElement paramOM = fac.createOMElement("param", namespace);
    paramOM.setText(Integer.toString(param));
    params.addChild(paramOM);
    envelope.getBody().setFirstChild(params);

    if (groupContextId != null) {
      OMNamespace axis2Namespace = fac.createOMNamespace(
View Full Code Here

     */
    private void extractDetails(AsyncResult result) {
        Iterator iterator, iterator2;
        OMNode node;
        SOAPBody body;
        OMElement operation, elem;
        SOAPEnvelope resEnvelope;
        resEnvelope = result.getResponseEnvelope();
        body = resEnvelope.getBody();
        operation = body.getFirstElement();
        if (body.hasFault()) {
            snippet =
                    snippet +
                    "A Fault message received, Check your Licence key. Else you have reached the" +
                    " daily limit of 1000 requests";
        } else {
            OMElement part = operation.getFirstElement();

            iterator = part.getChildren();
            while (iterator.hasNext()) {
                node = (OMNode) iterator.next();
                if (node.getType() == OMNode.ELEMENT_NODE) {
                    elem = (OMElement) node;
                    String str = elem.getLocalName();
View Full Code Here

     */
    public static MessageContext getMessageContext(
            AsynchronousClient asyncClient)
            throws AxisFault {
        OMNamespace defNs;
        OMElement operation;
        MessageContext msgContext = null;

        String str_ST_index = Integer.toString(asyncClient.getStartIndex());

        defNs = OMAbstractFactory.getSOAP11Factory().createOMNamespace("", "");
        SOAPFactory omFactory = OMAbstractFactory.getSOAP11Factory();
        SOAPEnvelope envelope = omFactory.getDefaultEnvelope();
        envelope.declareNamespace("http://schemas.xmlsoap.org/soap/envelope/",
                "soapenv");
        envelope.declareNamespace("http://schemas.xmlsoap.org/soap/encoding/",
                "SOAP-ENC");
        envelope.declareNamespace("http://www.w3.org/2001/XMLSchema-instance",
                "xsi");
        envelope.declareNamespace("http://www.w3.org/2001/XMLSchema",
                "xsd");

        operation =
                omFactory.createOMElement("doGoogleSearch",
                        "urn:GoogleSearch",
                        "ns1");
        envelope.getBody().addChild(operation);
        operation.addAttribute("soapenv:encordingStyle",
                "http://schemas.xmlsoap.org/soap/encoding/", null);

        operation.addChild(
                getOMElement(omFactory,
                        defNs,
                        "key",
                        "xsd:string",
                        asyncClient.getKey()));
        operation.addChild(
                getOMElement(omFactory,
                        defNs,
                        "q",
                        "xsd:string",
                        asyncClient.getSearch()));
        operation.addChild(
                getOMElement(omFactory,
                        defNs,
                        "start",
                        "xsd:int",
                        str_ST_index));
        operation.addChild(
                getOMElement(omFactory,
                        defNs,
                        "maxResults",
                        "xsd:int",
                        asyncClient.getMaxResults()));
        operation.addChild(
                getOMElement(omFactory,
                        defNs,
                        "filter",
                        "xsd:boolean",
                        "true"));
        operation.addChild(
                getOMElement(omFactory, defNs, "restrict", "xsd:string", ""));
        operation.addChild(
                getOMElement(omFactory,
                        defNs,
                        "safeSearch",
                        "xsd:boolean",
                        "false"));
        operation.addChild(
                getOMElement(omFactory, defNs, "lr", "xsd:string", ""));
        operation.addChild(
                getOMElement(omFactory, defNs, "ie", "xsd:string", "latin1"));
        operation.addChild(
                getOMElement(omFactory, defNs, "oe", "xsd:string", "latin1"));

        msgContext = new MessageContext();
        msgContext.setEnvelope(envelope);
        return msgContext;
View Full Code Here

        return msgContext;
    }

    private static OMElement getOMElement(OMFactory factory, OMNamespace ns, String elementName,
                                          String type, String text) {
        OMElement part = factory.createOMElement(elementName, ns);
        part.addAttribute("xsi:type", type, null);
        part.addChild(factory.createText(text));
        return part;
    }
View Full Code Here

public class EchoBlockingClient {
    private static EndpointReference targetEPR = new EndpointReference("http://localhost:8080/axis2/services/MyService");

    public static void main(String[] args) {
        try {
            OMElement payload = ClientUtil.getEchoOMElement();
            Options options = new Options();
            options.setTo(targetEPR);
            options.setTransportInProtocol(Constants.TRANSPORT_HTTP);

            //Blocking invocation
            ServiceClient sender = new ServiceClient();
            sender.setOptions(options);
            OMElement result = sender.sendReceive(payload);

            StringWriter writer = new StringWriter();
            result.serialize(XMLOutputFactory.newInstance()
                    .createXMLStreamWriter(writer));
            writer.flush();

            System.out.println(writer.toString());
View Full Code Here

    private static OMElement getPayload() {
        OMFactory fac = OMAbstractFactory.getOMFactory();
        OMNamespace omNs = fac.createOMNamespace(
                "http://example1.org/example1", "example1");
        OMElement method = fac.createOMElement("echo", omNs);
        OMElement value = fac.createOMElement("Text", omNs);
        value.addChild(fac.createText(value, "Axis2 Echo String "));
        method.addChild(value);

        return method;
    }
View Full Code Here

public class ClientForWebServiceWithModule {
    private static EndpointReference targetEPR = new EndpointReference("http://127.0.0.1:8080/axis2/services/MyServiceWithModule");

    public static void main(String[] args) {
        try {
            OMElement payload = ClientUtil.getEchoOMElement();
            Options options = new Options();
            options.setTo(targetEPR);
            options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
            ServiceClient sender = new ServiceClient();
            sender.setOptions(options);
            OMElement result = sender.sendReceive(payload);


            StringWriter writer = new StringWriter();
            result.serialize(XMLOutputFactory.newInstance()
                    .createXMLStreamWriter(writer));
            writer.flush();
            System.out.println(writer.toString());

View Full Code Here

        options.setProperty(Constants.Configuration.ENABLE_REST, Constants.VALUE_TRUE);

        ServiceClient sender = new ServiceClient();
        sender.engageModule(new QName(Constants.MODULE_ADDRESSING));
        sender.setOptions(options);
        OMElement result = sender.sendReceive(getPayload());

        try {
            XMLStreamWriter writer = XMLOutputFactory.newInstance()
                    .createXMLStreamWriter(System.out);
            result.serialize(writer);
            writer.flush();
        } catch (XMLStreamException e) {
            e.printStackTrace();
        } catch (FactoryConfigurationError e) {
            e.printStackTrace();
View Full Code Here

TOP

Related Classes of org.apache.axis2.om.OMElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.