1 pièce(s) jointe(s)
Android communication avec une passerelle Echelon
Bonjour,
Je souhaite pour l'instant créer une application Android permettant la communication avec une passerelle de chez Échelon fournie avec :
-les bibliothèques et dépendance
-un fichier POM.xml
En suivant leurs instructions et tutoriels j'ai créé un projet Java sous Eclipse permettant simplement de faire changer d'état deux relais de la passerelle et acquérir leurs positions.
Tout va bien jusqu'à ce que je tente la conversion avec le même code sous un projet Android.
Quand j'exécute la classe client en Java, cela fonctionne comme souhaité mais lors de l'appel de la même fonction sous Android mon application s’arrête de fonctionner.
Le Logcat d’Eclipse affiche alors:
Citation:
11-02 10:50:44.461: E/AndroidRuntime(665): FATAL EXCEPTION: main
11-02 10:50:44.461: E/AndroidRuntime(665): java.lang.IllegalStateException: Could not execute method of the activity
11-02 10:50:44.461: E/AndroidRuntime(665): at android.view.View$1.onClick(View.java:3591)
11-02 10:50:44.461: E/AndroidRuntime(665): at android.view.View.performClick(View.java:4084)
11-02 10:50:44.461: E/AndroidRuntime(665): at android.view.View$PerformClick.run(View.java:16966)
11-02 10:50:44.461: E/AndroidRuntime(665): at android.os.Handler.handleCallback(Handler.java:615)
11-02 10:50:44.461: E/AndroidRuntime(665): at android.os.Handler.dispatchMessage(Handler.java:92)
11-02 10:50:44.461: E/AndroidRuntime(665): at android.os.Looper.loop(Looper.java:137)
11-02 10:50:44.461: E/AndroidRuntime(665): at android.app.ActivityThread.main(ActivityThread.java:4745)
11-02 10:50:44.461: E/AndroidRuntime(665): at java.lang.reflect.Method.invokeNative(Native Method)
11-02 10:50:44.461: E/AndroidRuntime(665): at java.lang.reflect.Method.invoke(Method.java:511)
11-02 10:50:44.461: E/AndroidRuntime(665): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
11-02 10:50:44.461: E/AndroidRuntime(665): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-02 10:50:44.461: E/AndroidRuntime(665): at dalvik.system.NativeStart.main(Native Method)
11-02 10:50:44.461: E/AndroidRuntime(665): Caused by: java.lang.reflect.InvocationTargetException
11-02 10:50:44.461: E/AndroidRuntime(665): at java.lang.reflect.Method.invokeNative(Native Method)
11-02 10:50:44.461: E/AndroidRuntime(665): at java.lang.reflect.Method.invoke(Method.java:511)
11-02 10:50:44.461: E/AndroidRuntime(665): at android.view.View$1.onClick(View.java:3586)
11-02 10:50:44.461: E/AndroidRuntime(665): ... 11 more
11-02 10:50:44.461: E/AndroidRuntime(665): Caused by: java.lang.NoClassDefFoundError: com.echelon.wsdl.web_services_ns.ilon100.v4_0.wsdl.ILON100
11-02 10:50:44.461: E/AndroidRuntime(665): at com.echelon.sample.client.ilon.Client.Recup(Client.java:25)
11-02 10:50:44.461: E/AndroidRuntime(665): at com.echelon.sample.client.ilon.Principal.test(Principal.java:23)
11-02 10:50:44.461: E/AndroidRuntime(665): ... 14 more
11-02 10:50:49.991: I/Process(665): Sending signal. PID: 665 SIG: 9
Projet eclipse:
http://www.developpez.net/forums/att...1&d=1353329175
Client.class:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
| package com.echelon.sample.client.ilon;
import com.echelon.wsdl.web_services_ns.ilon100.v4_0.message.DpData;
import com.echelon.wsdl.web_services_ns.ilon100.v4_0.message.EXSelect;
import com.echelon.wsdl.web_services_ns.ilon100.v4_0.message.ItemColl;
import com.echelon.wsdl.web_services_ns.ilon100.v4_0.message.ItemDataColl;
import com.echelon.wsdl.web_services_ns.ilon100.v4_0.wsdl.ILON100;
import com.echelon.wsdl.web_services_ns.ilon100.v4_0.wsdl.ILON100PortType;
public class Client
{
public static void main (String[] args)
{
Recup();
}
public static void Recup()
{
ILON100 iLon100 = null;
ILON100PortType SmartServer = null;
try
{
iLon100 = new ILON100();
SmartServer = (iLon100).getILON100HttpPort();
try
{
// _________________________
// Soap::List
EXSelect xSelect = new EXSelect();
xSelect.setXSelect("//Item[@xsi:type=\"Dp_Cfg\"][contains(UCPTname,\"nviClaValue\")]");
ItemColl itemColl = SmartServer.list(xSelect);
if(0 < itemColl.getUCPTfaultCount()) {
System.out.printf("List-Response contains %s faults\r\n",itemColl.getUCPTfaultCount());
}
// just print the returned count of Item-s
System.out.println("Items returned = " + itemColl.getItem().size());
if(itemColl.getItem().size()> 0)
{
// _________________________
// Soap::Read
ItemDataColl itemDataColl = SmartServer.read(itemColl);
if(0 < itemDataColl.getUCPTfaultCount())
{
System.out.printf("Read-Response contains %s faults\r\n",itemColl.getUCPTfaultCount());
}
// just print some properties
for (int i = 0; i <itemColl.getItem().size(); i++)
{
System.out.print(((DpData)(itemDataColl.getItem().get(i))).getUCPTname()+ " = ");
System.out.print(((DpData)(itemDataColl.getItem().get(i))).getUCPTvalue().get(0).getValue() + "(Value Read)" + "\r\n");
DpData dpData = (DpData) itemDataColl.getItem().get(i);
if(dpData.getUCPTvalue().get(0).getValue().compareTo ("0.0 0")== 0)
{
dpData.getUCPTvalue().get(0).setValue("100.0 1");
dpData.getUCPTvalue().get(1).setValue("ON");
itemDataColl.getItem().add(dpData);
}
else if(dpData.getUCPTvalue().get(0).getValue().compareTo ("100.0 1")== 0)
{
dpData.getUCPTvalue().get(0).setValue("0.0 0");
dpData.getUCPTvalue().get(1).setValue("OFF");
itemDataColl.getItem().add(dpData);
}
}
ItemColl writeResponse = SmartServer.write(itemDataColl);
if(writeResponse.getUCPTfaultCount()> 0)
{
// print out error and exit
System.out.println("An error occurred:");
for (int j = 0; j <itemColl.getItem().size(); j++)
{
System.out.println("Item: " + itemColl.getItem().get(j).getUCPTname() + ",fault code: " + itemColl.getItem().get(j).getFault().getFaultcode() + ",fault string: " + itemColl.getItem().get(j).getFault().getFaultstring());
}
}
else
{
// success
System.out.println("\r\n" + "Write is successful");
for (int j = 0; j <itemColl.getItem().size(); j++)
{
System.out.print(((DpData)(itemDataColl.getItem().get(j))).getUCPTname()+" = ");
System.out.print(((DpData)(itemDataColl.getItem().get(j))).getUCPTvalue().get(0).getValue()+ "(Value Written)" + "\r\n");
}
}
}
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
finally
{
iLon100 = null;
SmartServer = null;
}
}
} |
Principal.class: (la classe main Android permet l'initialisation du Layout et l'appel à Client.Recup();)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| package com.echelon.sample.client.ilon;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
public class Principal extends Activity
{
@Override
public void onCreate (Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.layoutclient);
}
public void test (View V)
{
TextView tvw_affiche;
tvw_affiche=(TextView)this.findViewById(R.id.tvw_affiche);
tvw_affiche.setText("");
/*********************************************************/
Client.Recup();
/*********************************************************/
tvw_affiche.setText("OK");
}
} |
ILON100.class:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
| package com.echelon.wsdl.web_services_ns.ilon100.v4_0.wsdl;
import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
import javax.xml.ws.WebServiceException;
import javax.xml.ws.WebServiceFeature;
/**
* This class was generated by the JAX-WS RI.
* JAX-WS RI 2.2.7-b73
* Generated source version: 2.2
*
*/
@WebServiceClient(name = "iLON100", targetNamespace = "http://wsdl.echelon.com/web_services_ns/ilon100/v4.0/wsdl/", wsdlLocation = "file:/C:/Users/WIN7CLIMEL/workspace/ilon.ws.clients/jax-ws/src/wsdl/iLON100.wsdl")
public class ILON100
extends Service
{
private final static URL ILON100_WSDL_LOCATION;
private final static WebServiceException ILON100_EXCEPTION;
private final static QName ILON100_QNAME = new QName("http://wsdl.echelon.com/web_services_ns/ilon100/v4.0/wsdl/", "iLON100");
static {
URL url = null;
WebServiceException e = null;
try {
url = new URL("file:/C:/Users/WIN7CLIMEL/workspace/ilon.ws.clients/jax-ws/src/wsdl/iLON100.wsdl");
} catch (MalformedURLException ex) {
e = new WebServiceException(ex);
}
ILON100_WSDL_LOCATION = url;
ILON100_EXCEPTION = e;
}
public ILON100() {
super(__getWsdlLocation(), ILON100_QNAME);
}
public ILON100(WebServiceFeature... features) {
super(__getWsdlLocation(), ILON100_QNAME, features);
}
public ILON100(URL wsdlLocation) {
super(wsdlLocation, ILON100_QNAME);
}
public ILON100(URL wsdlLocation, WebServiceFeature... features) {
super(wsdlLocation, ILON100_QNAME, features);
}
public ILON100(URL wsdlLocation, QName serviceName) {
super(wsdlLocation, serviceName);
}
public ILON100(URL wsdlLocation, QName serviceName, WebServiceFeature... features) {
super(wsdlLocation, serviceName, features);
}
/**
*
* @return
* returns ILON100PortType
*/
@WebEndpoint(name = "iLON100httpPort")
public ILON100PortType getILON100HttpPort() {
return super.getPort(new QName("http://wsdl.echelon.com/web_services_ns/ilon100/v4.0/wsdl/", "iLON100httpPort"), ILON100PortType.class);
}
/**
*
* @param features
* A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values.
* @return
* returns ILON100PortType
*/
@WebEndpoint(name = "iLON100httpPort")
public ILON100PortType getILON100HttpPort(WebServiceFeature... features) {
return super.getPort(new QName("http://wsdl.echelon.com/web_services_ns/ilon100/v4.0/wsdl/", "iLON100httpPort"), ILON100PortType.class, features);
}
private static URL __getWsdlLocation() {
if (ILON100_EXCEPTION!= null) {
throw ILON100_EXCEPTION;
}
return ILON100_WSDL_LOCATION;
}
} |
Android Manifest:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.echelon.sample.client.ilon"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Client"
android:label="@string/app_name" >
</activity>
<activity
android:name=".Principal"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest> |
Fichier POM.xml
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
| <?xml version="1.0" encoding="UTF-8" ?>
<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>com.echelon.es</groupId>
<artifactId>ilon-ws</artifactId>
<version>4.03-SNAPSHOT</version>
<name>ECHELON i.LON SmartServer</name>
<packaging>jar</packaging>
<properties>
<ip-address-ilon>192.168.0.100</ip-address-ilon>
</properties>
<dependencies>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.2.7-promoted-b73</version>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>1.5_r4</version>
<scope>provided</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>java.net</id>
<url>http://download.java.net/maven/1/</url>
<layout>legacy</layout>
</repository>
<repository>
<id>java.net2</id>
<url>http://download.java.net/maven/2/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>java.net2</id>
<url>http://download.java.net/maven/2/</url>
</pluginRepository>
</pluginRepositories>
<build>
<!-- To define the plugin version -->
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.6</version>
</plugin>
</plugins>
</pluginManagement>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<!-- CALL: mvn javadoc:javadoc -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.6</version>
</plugin>
<!-- CALL: mvn jaxws:wsimport -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
</execution>
</executions>
<configuration>
<verbose>true</verbose>
<!-- +++++++++++++++++++++++++++++++++ -->
<!-- get the WSDL file from the i.LON -->
<!-- +++++++++++++++++++++++++++++++++ -->
<!-- wsdlUrls>
<wsdlUrl>http://${ip-address-ilon}:80/WSDL/v4.0/iLON100.wsdl</wsdlUrl>
</wsdlUrls -->
<!-- +++++++++++++++++++++++++++++++++++++++ -->
<!-- get the WSDL file from the a directory -->
<!-- +++++++++++++++++++++++++++++++++++++++ -->
<wsdlDirectory>${basedir}/src/wsdl</wsdlDirectory>
<wsdlFiles>
<wsdlFile>iLON100.wsdl</wsdlFile>
</wsdlFiles>
<!-- packageName>fromwsdl.client</packageName -->
</configuration>
<!-- if you want to use a specific version of JAX-WS -->
<dependencies>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-tools</artifactId>
<version>2.2.7-promoted-b73</version>
</dependency>
</dependencies>
</plugin>
<!-- Don't forget Java 5!! -->
<!-- CALL: mvn compiler:compile -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<verbose>true</verbose>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<!-- CALL: mvn source:jar -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<phase>verify</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<verbose>true</verbose>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.5</version>
</plugin>
</plugins>
</reporting>
</project> |
Je remercie d'avance toutes les personne qui se pencheront sur mon problème.