Bonjour voilà etant debutant en programmation android et webservice
j'ai décidé de suivre un tuto simple pour crée un webservice qui m'affiche juste un "Hello Man" sur mon emulateur android , le probleme c'est que sa marche pas je n'obtien rien quand je lance l'emulateur et je comprend pas qu'elle en ai la cause
Voici le code du webservice
et voici le code Android
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 package com.android.ws; public class PrintMsg { public String sayHello(){ return "Hello Man"; } }
J'ai Autorisé l'accees a internet dans le manifeste se serais vraiment sympa de m'aider je bug depuis 15 jours la dessus
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 package com.androidclient.ws; 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 android.widget.TextView; import android.app.Activity; import android.os.Bundle; public class WSClientActivity extends Activity { private static final String SOAP_ACTION = "http://ws.android.com/sayHello"; private static final String METHOD_NAME = "sayHello"; private static final String NAMESPACE = "http://ws.android.com/"; private static final String URL = "http://mon adresse Ip:8085/PrintMsg/services/PrintMsg?wsdl"; TextView tv ; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); tv=(TextView)findViewById(R.id.tv); SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.setOutputSoapObject(request); HttpTransportSE ht = new HttpTransportSE(URL); try { ht.call(SOAP_ACTION, envelope); SoapPrimitive response = (SoapPrimitive)envelope.getResponse(); tv.setText("Message :"+response); setContentView(tv); } catch (Exception e) { e.printStackTrace(); } } }
Partager