Here is my code for the project

Weather class
===================================
package samples.demo;


public class Weather{
    float temperature;
    String forecast;
    boolean rain;
    float howMuchRain;
    
    public void setTemperature(float temp){
        temperature = temp;
    }

    public float getTemperature(){
        return temperature;
    }
    
    public void setForecast(String fore){
        forecast = fore;
    }

    public String getForecast(){
        return forecast;
    }
    
    public void setRain(boolean r){
        rain = r;
    }

    public boolean getRain(){
        return rain;
    }
    
    
    public void setHowMuchRain(float howMuch){
        howMuchRain = howMuch;
    }

    public float getHowMuchRain(){
        return howMuchRain;
    }
}
=====================================

Weather service

=====================================
package samples.demo;

public class WeatherService{
    Weather weather;
    
    public void setWeather(Weather weather){
        this.weather = weather;
    }

    public Weather getWeather(){
        
        Weather w = new Weather();
         w.setTemperature((float)50.6);
         w.setForecast("Cloudy with sun");
         w.setRain(false);
         w.setHowMuchRain((float)2.5);
        
        return w;
    }
}
=====================================

RPCClient
=====================================
package samples.demo;

import javax.xml.namespace.QName;

import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client.RPCServiceClient;


public class WeatherRPCClient {

    public static void main(String[] args1) throws AxisFault {

        RPCServiceClient serviceClient = new RPCServiceClient();

        Options options = serviceClient.getOptions();

       EndpointReference targetEPR = new
EndpointReference("http://localhost:8080/axis2-book-1.1/services/WeatherService";);
       options.setTo(targetEPR);

        // Setting the weather
        QName opSetWeather = new QName("http://demo.samples";, "setWeather");

        Weather w = new Weather();

        w.setTemperature((float)39.6);
        w.setForecast("Cloudy with showers");
        w.setRain(true);
        w.setHowMuchRain((float)4.5);

        Object[] opSetWeatherArgs = new Object[] { w };

        //serviceClient.invokeBlocking(opSetWeather, opSetWeatherArgs);
        serviceClient.invokeRobust(opSetWeather, opSetWeatherArgs);
        

        // Getting the weather
        QName opGetWeather = new QName("http://demo.samples";, "getWeather");

        Object[] opGetWeatherArgs = new Object[] { };
        Class[] returnTypes = new Class[] { Weather.class };
        
        
        Object[] response = serviceClient.invokeBlocking(opGetWeather,
                opGetWeatherArgs, returnTypes);
        
        Weather result = (Weather) response[0];
        
        if (result == null) {
            System.out.println("Weather didn't initialize!");
            return;
        }
        
        // Displaying the result
        System.out.println("Temperature               : " +
                           result.getTemperature());
        System.out.println("Forecast                  : " +
                           result.getForecast());
        System.out.println("Rain                      : " +
                           result.getRain());
        System.out.println("How much rain (in inches) : " +
                           result.getHowMuchRain());
        
       
    }
}

=====================================

web.xml
=====================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd";>
    
<web-app>

    <servlet>
        <servlet-name>AxisServlet</servlet-name>
        <display-name>Apache-Axis Servlet</display-name>
        <servlet-class>
            org.apache.axis2.transport.http.AxisServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

  <servlet-mapping>
    <servlet-name>AxisServlet</servlet-name>
    <url-pattern>/services/*</url-pattern>
  </servlet-mapping>
</web-app>
=========================================

pom.xml
=========================================
<project xmlns="http://maven.apache.org/POM/4.0.0";
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd";>
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.apache.axis2.examples</groupId>
    <artifactId>axis2-book</artifactId>
    <name>Book Example</name>
    <version>1.1</version>
    <inceptionYear>2004</inceptionYear>

    <dependencies>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.4</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-kernel</artifactId>
            <version>1.3</version>
        </dependency>
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-codegen</artifactId>
            <version>1.3</version>
        </dependency>
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-adb</artifactId>
            <version>1.3</version>
        </dependency>
        <dependency>
            <groupId>org.apache.ws.commons.axiom</groupId>
            <artifactId>axiom-api</artifactId>
            <version>1.2.5</version>
        </dependency>
        <dependency>
            <groupId>org.apache.ws.commons.axiom</groupId>
            <artifactId>axiom-impl</artifactId>
            <version>1.2.5</version>
        </dependency>
        <dependency>
            <groupId>org.apache.ws.commons.schema</groupId>
            <artifactId>XmlSchema</artifactId>
            <version>1.3.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.neethi</groupId>
            <artifactId>neethi</artifactId>
            <version>2.0</version>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.0.4</version>
        </dependency>
        <dependency>
            <groupId>commons-httpclient</groupId>
            <artifactId>commons-httpclient</artifactId>
            <version>3.0.1</version>
        </dependency>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.3</version>
        </dependency>
        <dependency>
            <groupId>woodstox</groupId>
            <artifactId>wstx</artifactId>
            <version>asl-2.9.3</version>
        </dependency>
        <dependency>
            <groupId>stax</groupId>
            <artifactId>stax-api</artifactId>
            <version>1.0.1</version>
        </dependency>
        <dependency>
            <groupId>wsdl4j</groupId>
            <artifactId>wsdl4j</artifactId>
            <version>1.5.2</version>
        </dependency>
        <dependency>
            <groupId>geronimo-spec</groupId>
            <artifactId>geronimo-spec-javamail</artifactId>
            <version>1.3.1-rc5</version>
        </dependency>
        <dependency>
            <groupId>geronimo-spec</groupId>
            <artifactId>geronimo-spec-activation</artifactId>
            <version>1.0.2-rc4</version>
        </dependency>
        <dependency>
            <groupId>xmlbeans</groupId>
            <artifactId>xbean</artifactId>
            <version>2.1.0</version>
        </dependency>
        <dependency>
            <groupId>jaxen</groupId>
            <artifactId>jaxen</artifactId>
            <version>1.1-beta-8</version>
        </dependency>
        <dependency>
            <groupId>backport-util-concurrent</groupId>
            <artifactId>backport-util-concurrent</artifactId>
            <version>2.1</version>
        </dependency>
        <dependency>
            <groupId>annogen</groupId>
            <artifactId>annogen</artifactId>
            <version>0.1.0</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                   
<warSourceDirectory>${basedir}/src/webapp</warSourceDirectory>
                </configuration>
            </plugin>
        </plugins>
        <sourceDirectory>src/main</sourceDirectory>
        <testSourceDirectory>src/test</testSourceDirectory>
        <resources>
            <resource>
                <directory>src/main</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
            </resource>
        </resources>
        <testResources>
            <testResource>
                <directory>src/test</directory>
                <includes>
                    <include>**/*.xml</include>
                    <include>**/*.properties</include>
                    <include>**/*.wsdl</include>
                </includes>
            </testResource>
        </testResources>
    </build>

    <!--  needed for XmlSchema -->
    <repositories>
        <repository>
            <id>ibiblio</id>
            <name>ibiblio maven repository</name>
            <url>http://ibiblio.org/maven/</url>
            <layout>legacy</layout>
        </repository>
        <repository>
            <id>apache</id>
            <name>Apache maven repository</name>
            <url>http://www.apache.org/dist/java-repository/</url>
            <layout>legacy</layout>
        </repository>
    </repositories>

</project>

=========================================

service.xml in / src/webapp/WEB-INF/services/WeatherService/META-INF
========================================
<service name="WeatherService" scope="application">
    <description>
        Weather POJO Service
    </description>
    <messageReceivers>
        <messageReceiver 
            mep="http://www.w3.org/2004/08/wsdl/in-only";
    class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
        <messageReceiver
            mep="http://www.w3.org/2004/08/wsdl/in-out";
    class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
    </messageReceivers>
    <parameter name="ServiceClass" locked="false">
        samples.demo.WeatherService
    </parameter>
</service>
============================================

This does not use servicegroup but how can I do this?

-- 
View this message in context: 
http://www.nabble.com/Tutorial-on-light-Service-and-Client-tf4371608.html#a12476826
Sent from the Axis - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to