J'ai une application android développée sur éclipse qui se connecte sur les webservices de Sugarcrm.La premire tache dans le projet est se connecter au webservice "login" de sugarcrm.
J'ai besoin de votre aide
MainActivity.java:
erreur:
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
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 package com.example.sugardev; import org.ksoap2.SoapEnvelope; import org.ksoap2.serialization.SoapObject; import org.ksoap2.serialization.SoapSerializationEnvelope; import org.ksoap2.transport.HttpTransportSE; import android.annotation.SuppressLint; import android.app.Activity; import android.os.Bundle; import android.os.StrictMode; import android.util.Log; import android.view.Menu; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class MainActivity extends Activity { private static String SOAP_ACTION = "http://192.168.2.219:40/SugarCE-Full-6.5.0/SOAP.php/login"; private static String NAMESPACE = "http://www.sugarcrm.com/sugarcrm"; private static String METHOD_NAME = "login"; private static String URL = "http://192.168.2.219:40/SugarCE-Full-6.5.0/SOAP.php?wsdl"; private static final String TAG = "MainActivity"; @SuppressLint("NewApi") @Override protected void onCreate(Bundle savedInstanceState) { StrictMode.enableDefaults(); //this line add super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final EditText editText1 = (EditText) findViewById(R.id.loginText); final EditText editText2 = (EditText) findViewById(R.id.mdpText); Button btn = (Button) findViewById(R.id.buttonlog); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Thread thread = new Thread() { @Override public void run() { SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); request.addProperty("user_name", (editText1.getText().toString())); request.addProperty("password", (editText2.getText().toString())); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.setOutputSoapObject(request); envelope.dotNet = true; try { HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); androidHttpTransport.call(SOAP_ACTION, envelope); Object result = envelope.getResponse(); if(result != null) { // String[] results = (String[]) result; // TextView editText3 = null; //editText3.setText(results[0]); System.out.println("success"); } else { Toast.makeText(getApplicationContext(), "No Response",Toast.LENGTH_LONG).show(); } } catch (Exception e) { e.printStackTrace(); } } }; thread.start(); } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.activity_main, menu); return true; } }
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 04-22 20:19:23.640: W/System.err(845): java.net.ConnectException: failed to connect to /192.168.2.219 (port 40): connect failed: ETIMEDOUT (Connection timed out) 04-22 20:19:23.650: W/System.err(845): at libcore.io.IoBridge.connect(IoBridge.java:114) 04-22 20:19:23.650: W/System.err(845): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192) 04-22 20:19:23.660: W/System.err(845): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459) 04-22 20:19:23.660: W/System.err(845): at java.net.Socket.connect(Socket.java:842) 04-22 20:19:23.682: W/System.err(845): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:76) 04-22 20:19:23.690: W/System.err(845): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50) 04-22 20:19:23.690: W/System.err(845): at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:340) 04-22 20:19:23.710: W/System.err(845): at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87) 04-22 20:19:23.710: W/System.err(845): at libcore.net.http.HttpConnection.connect(HttpConnection.java:128) 04-22 20:19:23.710: W/System.err(845): at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:316) 04-22 20:19:23.710: W/System.err(845): at libcore.net.http.HttpEngine.connect(HttpEngine.java:311) 04-22 20:19:23.710: W/System.err(845): at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:290) 04-22 20:19:23.720: W/System.err(845): at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:240) 04-22 20:19:23.730: W/System.err(845): at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:81) 04-22 20:19:23.730: W/System.err(845): at org.ksoap2.transport.ServiceConnectionSE.connect(Unknown Source) 04-22 20:19:23.730: W/System.err(845): at org.ksoap2.transport.HttpTransportSE.call(Unknown Source) 04-22 20:19:23.740: W/System.err(845): at com.example.sugardev.MainActivity$1$1.run(MainActivity.java:59) 04-22 20:19:23.757: W/System.err(845): Caused by: libcore.io.ErrnoException: connect failed: ETIMEDOUT (Connection timed out) 04-22 20:19:23.760: W/System.err(845): at libcore.io.Posix.connect(Native Method) 04-22 20:19:23.779: W/System.err(845): at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:85) 04-22 20:19:23.779: W/System.err(845): at libcore.io.IoBridge.connectErrno(IoBridge.java:127) 04-22 20:19:23.779: W/System.err(845): at libcore.io.IoBridge.connect(IoBridge.java:112) 04-22 20:19:23.779: W/System.err(845): ... 16 more
Partager