connexion a un wsdl via ksoap1.1
Bonjour,
Je Tente toujours d'établir la connexion avec une passerelle échelon mais par un autre moyen que ce qui me posait problème dans ce ticket:
http://www.developpez.net/forums/d12...relle-echelon/
Je suis donc partie sur de nouvelle base et explorer les "différent possibilité de package SOAP" J'ai arrêté mon choix sur le KSoap.
Le transfère de ce dernier sur l'AVD fonctionne mais quand je tente une requête, mon application freeze.
J'ai donc encastrer le tout dans un try catch et afficher l'erreur.
Mon logcat me donne alors:
Logcat:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
11-22 12:20:57.690: E/Trace(914): error opening trace file: No such file or directory (2)
11-22 12:20:58.590: D/gralloc_goldfish(914): Emulator without GPU emulation detected.
11-22 12:21:08.110: E/Erreur Connexion(914): pb IO
11-22 12:21:08.110: E/Erreur Connexion(914): java.lang.ClassCastException: libcore.net.url.FileURLConnection cannot be cast to java.net.HttpURLConnection
11-22 12:21:08.110: E/Erreur Connexion(914): at org.ksoap2.transport.ServiceConnectionSE.<init>(ServiceConnectionSE.java:39)
11-22 12:21:08.110: E/Erreur Connexion(914): at org.ksoap2.transport.HttpTransportSE.getServiceConnection(HttpTransportSE.java:104)
11-22 12:21:08.110: E/Erreur Connexion(914): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:61)
11-22 12:21:08.110: E/Erreur Connexion(914): at com.myconnexionsoap.Connexion.ValRelais(Connexion.java:80)
11-22 12:21:08.110: E/Erreur Connexion(914): at java.lang.reflect.Method.invokeNative(Native Method)
11-22 12:21:08.110: E/Erreur Connexion(914): at java.lang.reflect.Method.invoke(Method.java:511)
11-22 12:21:08.110: E/Erreur Connexion(914): at android.view.View$1.onClick(View.java:3586)
11-22 12:21:08.110: E/Erreur Connexion(914): at android.view.View.performClick(View.java:4084)
11-22 12:21:08.110: E/Erreur Connexion(914): at android.view.View$PerformClick.run(View.java:16966)
11-22 12:21:08.110: E/Erreur Connexion(914): at android.os.Handler.handleCallback(Handler.java:615)
11-22 12:21:08.110: E/Erreur Connexion(914): at android.os.Handler.dispatchMessage(Handler.java:92)
11-22 12:21:08.110: E/Erreur Connexion(914): at android.os.Looper.loop(Looper.java:137)
11-22 12:21:08.110: E/Erreur Connexion(914): at android.app.ActivityThread.main(ActivityThread.java:4745)
11-22 12:21:08.110: E/Erreur Connexion(914): at java.lang.reflect.Method.invokeNative(Native Method)
11-22 12:21:08.110: E/Erreur Connexion(914): at java.lang.reflect.Method.invoke(Method.java:511)
11-22 12:21:08.110: E/Erreur Connexion(914): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
11-22 12:21:08.110: E/Erreur Connexion(914): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-22 12:21:08.110: E/Erreur Connexion(914): at dalvik.system.NativeStart.main(Native Method) |
J'attire votre attention sur la ligne 2 pour laquelle je comprend ce qu'elle signifie mais alors pourquoi elle est la et ce généré au moment de l'ouverture de l'application.
Code:
11-22 12:20:57.690: E/Trace(914): error opening trace file: No such file or directory (2)
Voila je vous fournie mon code:
Connexion.java
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
|
package com.myconnexionsoap;
/****
* dépendance android
*/
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
/****
* dépendance de ksoap
*/
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.ksoap2.serialization.PropertyInfo;
/****
* dépendance de echelon
* 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 Connexion extends Activity
{
/****
* declaration de l'adresse et des methodes
*/
private static final String NAMESPACE = "http://wsdl.echelon.com/web_services_ns/ilon100/v4.0/wsdl/";
private static String URL="file:/C:/Users/WIN7CLIMEL/workspace/MyConnexionSoap/src/wsdl/iLON100.wsdl";
private static final String METHOD_NAME = "List";
private static final String SOAP_ACTION = "http://wsdl.echelon.com/web_services_ns/ilon100/v4.0/wsdl/List";
/****
* S'éffectue la première fois que l'activité ce lance:
* Initialisation de l'activité
*/
@Override
public void onCreate (Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_connexion);
}/*** end public void onCreate (Bundle savedInstanceThread) ***/
/****
* Methode OnClick "ValRelais" de @+id/btn_TestValRelais
* @param V
*/
@SuppressWarnings("deprecation")
public void ValRelais (View V)
{
//Declaration de lblResult qui transferera sa valeur a tvw_result
TextView lblResult = (TextView)findViewById(R.id.tvw_result);
//Nouveau message SOAP
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
//proprietées de la requette Read
PropertyInfo propInfo=new PropertyInfo();
propInfo.name="IlonItem";
//propInfo.type=PropertyInfo.STRING_CLASS;
request.addProperty(propInfo, "E_xSelect");
//creation d'une envellope soap et assignation en tent que requêt
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
//creation de
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try //connexion OK
{
//envoie du message
androidHttpTransport.call(SOAP_ACTION, envelope);
//réponse
SoapPrimitive resultsRequestSOAP = (SoapPrimitive) envelope.getResponse();
//Affichage reponse
lblResult.setText(resultsRequestSOAP.toString());
}
catch (Exception e) //connexion NOK: afficher l'exeption
{
//Affiche l'exeption clairement dans le logcat
Log.e("Erreur Connexion","pb IO",e);
}
}/*** public void ValRelais (View V) ***/
}/*** end public class Connexion extends Activity ***/ |
AndroidManifest.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
|
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myconnexionsoap"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.myconnexionsoap.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.myconnexionsoap.Connexion"
android:label="@string/app_name">
</activity>
</application>
</manifest> |
Étant débutant en SOAP->WSDL je pense que c'est une erreur stupide mais je me casse les dent dessus... :aie:
Merci de vos réponse franche. ;)