apim_4xx_support_multiple_analytics_publishers APIM manage workflow with multiple roles APIM 3.0.0 per API based subscription workflow Logging internal HTTP requests Log APIM analytics events to a file Monetization and sample with WSO2 API Manager 2.6.0 Share application and subscription among a set of specific groups or roles WSO2 APIM Correlating analytics event with correlationID APIM analytics distinguish production and sandbox traffic APIM 2.x.x analytics internal and analytics tuneup Configure APIM(Next release) Key Manager User stores APIM(Next release) working with key manager DAS 3.x Parse system variables to Spark Context Revoke OAuth application In APIM 2.1.0 Next WSO2 APIM powered by WSO2 Ballerina Configure WSO2 APIM Analytics on Cluster environment Configure WSO2 DAS 3.1.0 for WSO2 APIM 2.0.0 Analytics WSO2 APIM publishing custom statistics WSO2 APIM Error codes Working with WSO2 message tracer Use DAS admin service to query using Spark SQL Configure WSO2 APIM Analytics using XML WSO2 APIM Generating and Retrieving Custom Statistics Understanding WSO2 APIM Statistics Model Publishing WSO2 APIM 1.10.x Runtime Statistics to DAS with RDBMS Publishing_APIM_1100_Runtime_Statistics_to_DAS Aggregate functions with WSO2 DAS REST API Create a cApp for WSO2 DAS Debugging WSO2 Products using OSGI console. Publishing APIM Runtime Statistics to DAS Deploy cApp on WSO2 DAS How to configure and start the Accumulo minicluster How to setup DNS server on Ubuntu and Ubuntu server How to use Java Reflection how to install apache web server on ubuntu and ubuntu server How to install Mail server on Ubuntu and Ubuntu server How to install squirrelmail webmail client on Ubuntu and Ubuntu Server Pass and return String value to JNI method Pass and return numeric value to JNI method Calling a C Function from the Java Programming Language using JNI AXIS 2 Sample web service Client with maven and eclipse How to setup AXIS 2 with Apache Tomcat AXIS 2 Sample web service with maven and eclipse Robot framework Sample with Selenium Robot framework Custom Library Sample Behaviour-Driven Development with JBehave and Eclipse Play Audio with Netbeans and linking with LibVLC Implement LibVLC based player with QT-part2 Simple Audio playing sample with LibVLC How to install LibVLC on Ubuntu Implement LibVLC based player with QT-part1
AXIS 2 Sample web service with maven and eclipse
  1. Create meven project in eclipse

  1. Create Calculator Service Class

    • Create new package name as com.ruks.services
    • Create Caculator.java class inside the package.
    • Copy the below code to Caculator.java
        package com.ruks.serivces;

        public class Calculator {

            private static Calculator cal;
            private int X=1;
            private int Y=2;
            private int Result;

            private Calculator(){

            }

            public static Calculator getCal(){
                if(cal==null){
                    cal=new Calculator();
                }
                return cal;
            }

            public void setX(int x){
                this.X=x;
        //		System.out.println("set x: "+CalculatorService.X+" = "+x);
            }
            public void setY(int y){
                this.Y=y;
        //		System.out.println("set y: "+CalculatorService.Y+" = "+y);
            }
            public int getSum(){
                this.Result=this.X+this.Y;
        //		System.out.println("GET result: "+this.Result);
                return this.Result;
            }
        }

    
    • Create CaculatorService.java class inside the package.
    • Copy the code below to CaculatorService.java
        package com.ruks.serivces;

        public class CalculatorService {

            Calculator cal;

            public CalculatorService() {
                cal=Calculator.getCal();
            }

            public void setX(int x){
                cal.setX(x);
        //		System.out.println("set x: "+CalculatorService.X+" = "+x);
            }
            public void setY(int y){
                cal.setY(y);
        //		System.out.println("set y: "+CalculatorService.Y+" = "+y);
            }
            public int getSum(){
                return cal.getSum();
            }
        }


  
  1. Create service.xml file

    • Add a xml file to main/resources as service.xml
    • Add the this to the service.xml
        <?xml version="1.0" encoding="UTF-8"?>
        <service name="CalculatorService">

            <description>
                Simple Calculator Implemantain
            </description>

            <parameter name="ServiceClass">com.ruks.serivces.CalculatorService</parameter>

            <operation name="setX" mep="http://www.w3.org/ns/wsdl/in-out" namespace="http://serivces.ruks.com/xsd">
                <actionMapping>http://serivces.ruks.com/xsd/setX</actionMapping>;
                <messageReceiver class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver" />;
            </operation>;

            <operation name="setY" mep="http://www.w3.org/ns/wsdl/in-out" namespace="http://serivces.ruks.com/xsd">;
                <actionMapping>;http://serivces.ruks.com/xsd/setY</actionMapping>;
                <messageReceiver class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver" />;
            </operation>;

            <operation name="getSum" mep="http://www.w3.org/ns/wsdl/in-out" namespace="http://serivces.ruks.com/xsd">;
                <actionMapping>;http://serivces.ruks.com/xsd/getSum</actionMapping>;
                <messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />;
            </operation>;

        </service>;
    
  1. Edit the pom.xml

    • add the axis2-java2wsdl-maven-plugin
        <plugin>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-java2wsdl-maven-plugin</artifactId>
            <configuration>
                <className>com.ruks.services.CalculatorService</className>
                <outputFileName>${project.build.directory}/CalculatorService.wsdl</outputFileName>
            </configuration>
            <executions>
                <execution>
                    <phase>process-classes</phase>
                    <goals>
                        <goal>java2wsdl</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    
    • add the axis2-aar-maven-plugin
        <plugin>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-aar-maven-plugin</artifactId>
            <configuration>
                <servicesXmlFile>${basedir}/src/resources/services.xml</servicesXmlFile>
                <wsdlFile>${project.build.directory}/CalculatorService.wsdl</wsdlFile>
            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>aar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
  
  1. Build the achive

  • Execute maven goal clean package to create aar achive
  • appropriate wsdl file and aar file will be created in the target directory
  1. Deploy the web service

  • Copy the Caculator.aar and paste to apache-tomcat/webapps/axis2/WEB-INF/services
  • Start the tomcat
  1. Verify the Service

    • Start the SoapUI
    • Navigate to http://localhost:8080/axis2/services/listServices
    • Make sure CalculatorService is listed
    • Click the CalculatorService and you get the WSDL URL
    • copy WSDL URL
    • Create new SoapUI soap Project
    • Add the URL to initial WSDL text box
    • Select the Soap Binding
    • Set the SetX request as below
        <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.ruks.com">
           <soapenv:Header/>
           <soapenv:Body>
              <ser:setX>
                 <!--Optional:-->
                 <ser:x>10</ser:x>
              </ser:setX>
           </soapenv:Body>
        </soapenv:Envelope>
    
    • Set the SetY request as below
        <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.ruks.com">
           <soapenv:Header/>
           <soapenv:Body>
              <ser:setY>
                 <!--Optional:-->
                 <ser:y>20</ser:y>
              </ser:setY>
           </soapenv:Body>
        </soapenv:Envelope>
    
    • Run the getSum request to see output
        <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
           <soapenv:Body>
              <ns:getSumResponse xmlns:ns="http://services.ruks.com">
                 <ns:return>30</ns:return>
              </ns:getSumResponse>
           </soapenv:Body>
        </soapenv:Envelope>
  

Add Comment

* Required information
1000
Powered by Commentics

Comments (0)

No comments yet. Be the first!