Salve ragazzi sto cercando di implementare il web service spiegato sul tutorial di apache axis 2 http://ws.apache.org/axis2/1_2/pojoguide.html, ma un problema per quanto riguarda la compilazione della classe client di test. Di seguti vi riporto come ho operato:
1. ho modificato il file C:\projects\axis-2_0\axis2-1.3\samples\pojoguide\build.xml nella seguente maniera:
codice:
<property name="axis2.home" value="C:\projects\axis-2_0\axis2-1.3" />
2. Ho effettuato il deploy di build.xml con ant:
codice:
C:\projects\axis-2_0\axis2-1.3\samples\pojoguide>ant generate.service
Buildfile: build.xml
clean:
prepare:
[mkdir] Created dir: C:\projects\axis-2_0\axis2-1.3\samples\pojoguide\build
[mkdir] Created dir: C:\projects\axis-2_0\axis2-1.3\samples\pojoguide\build\
lib
[mkdir] Created dir: C:\projects\axis-2_0\axis2-1.3\samples\pojoguide\build\
WeatherService
[mkdir] Created dir: C:\projects\axis-2_0\axis2-1.3\samples\pojoguide\build\
WeatherService\META-INF
generate.service:
[copy] Copying 1 file to C:\projects\axis-2_0\axis2-1.3\samples\pojoguide\b
uild\WeatherService\META-INF
[javac] Compiling 2 source files to C:\projects\axis-2_0\axis2-1.3\samples\p
ojoguide\build\WeatherService
[jar] Building jar: C:\projects\axis-2_0\axis2-1.3\samples\pojoguide\build
\WeatherService.aar
[copy] Copying 1 file to C:\projects\axis-2_0\axis2-1.3\repository\services
BUILD SUCCESSFUL
3. Ho copiato la cartella C:\projects\axis-2_0\axis2-1.3\samples\pojoguide\build\WeatherService in <tomcat-home>/webapps/axis2/WEB-INF/services
4. per compilare il client RPCServiceClient.java
codice:
package sample.pojo.rpcclient;
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;
import sample.pojo.data.Weather;
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/services/WeatherService");
options.setTo(targetEPR);
// Setting the weather
QName opSetWeather = new QName("http://service.pojo.sample", "setWeather");
Weather w = new Weather();
w.setTemperature((float)39.3);
w.setForecast("Cloudy with showers");
w.setRain(true);
w.setHowMuchRain((float)4.5);
Object[] opSetWeatherArgs = new Object[] { w };
serviceClient.invokeRobust(opSetWeather, opSetWeatherArgs);
// Getting the weather
QName opGetWeather = new QName("http://service.pojo.sample", "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());
}
}
l'ho copiato nella cartella C:\Programmi\Apache Software Foundation\Tomcat 5.5\webapps\axis2\WEB-INF\services\WeatherService\sample\pojo\rpcclient (cioè nel package generato e copiato al punto 3) in modo tale che possa usufruire delle classi compilate richieste cioè sample.pojo.data.Weather
5. ma al momento della compilazione mi compare il seguente messaggio di errore:
codice:
C:\Programmi\Apache Software Foundation\Tomcat 5.5\webapps\axis2\WEB-INF\service
s\WeatherService\sample\pojo\rpcclient>dir
Il volume nell'unità C non ha etichetta.
Numero di serie del volume: D4A6-E203
Directory di C:\Programmi\Apache Software Foundation\Tomcat 5.5\webapps\axis2\W
EB-INF\services\WeatherService\sample\pojo\rpcclient
21/12/2007 11.37 <DIR> .
21/12/2007 11.37 <DIR> ..
07/08/2007 14.37 3.028 WeatherRPCClient.java
1 File 3.028 byte
2 Directory 25.705.828.352 byte disponibili
C:\Programmi\Apache Software Foundation\Tomcat 5.5\webapps\axis2\WEB-INF\service
s\WeatherService\sample\pojo\rpcclient>javac *.java
WeatherRPCClient.java:23: package org.apache.axis2 does not exist
import org.apache.axis2.AxisFault;
^
WeatherRPCClient.java:24: package org.apache.axis2.addressing does not exist
import org.apache.axis2.addressing.EndpointReference;
^
WeatherRPCClient.java:25: package org.apache.axis2.client does not exist
import org.apache.axis2.client.Options;
^
WeatherRPCClient.java:26: package org.apache.axis2.rpc.client does not exist
import org.apache.axis2.rpc.client.RPCServiceClient;
^
WeatherRPCClient.java:28: package sample.pojo.data does not exist
import sample.pojo.data.Weather;
^
WeatherRPCClient.java:33: cannot find symbol
symbol : class AxisFault
location: class sample.pojo.rpcclient.WeatherRPCClient
public static void main(String[] args1) throws AxisFault {
^
WeatherRPCClient.java:35: cannot find symbol
symbol : class RPCServiceClient
location: class sample.pojo.rpcclient.WeatherRPCClient
RPCServiceClient serviceClient = new RPCServiceClient();
^
WeatherRPCClient.java:35: cannot find symbol
symbol : class RPCServiceClient
location: class sample.pojo.rpcclient.WeatherRPCClient
RPCServiceClient serviceClient = new RPCServiceClient();
^
WeatherRPCClient.java:37: cannot find symbol
symbol : class Options
location: class sample.pojo.rpcclient.WeatherRPCClient
Options options = serviceClient.getOptions();
^
WeatherRPCClient.java:39: cannot find symbol
symbol : class EndpointReference
location: class sample.pojo.rpcclient.WeatherRPCClient
EndpointReference targetEPR = new EndpointReference("http://localhost:80
80/axis2/services/WeatherService");
^
WeatherRPCClient.java:39: cannot find symbol
symbol : class EndpointReference
location: class sample.pojo.rpcclient.WeatherRPCClient
EndpointReference targetEPR = new EndpointReference("http://localhost:80
80/axis2/services/WeatherService");
^
WeatherRPCClient.java:46: cannot find symbol
symbol : class Weather
location: class sample.pojo.rpcclient.WeatherRPCClient
Weather w = new Weather();
^
WeatherRPCClient.java:46: cannot find symbol
symbol : class Weather
location: class sample.pojo.rpcclient.WeatherRPCClient
Weather w = new Weather();
^
WeatherRPCClient.java:62: cannot find symbol
symbol : class Weather
location: class sample.pojo.rpcclient.WeatherRPCClient
Class[] returnTypes = new Class[] { Weather.class };
^
WeatherRPCClient.java:68: cannot find symbol
symbol : class Weather
location: class sample.pojo.rpcclient.WeatherRPCClient
Weather result = (Weather) response[0];
^
WeatherRPCClient.java:68: cannot find symbol
symbol : class Weather
location: class sample.pojo.rpcclient.WeatherRPCClient
Weather result = (Weather) response[0];
^
16 errors
scusate se sono prolisso ma cerco di essere quanto più esaustivo e possibile!