I am developing an android application, I want to connect it to a web-service , Any ideas about how to make a web request and receive the response? N.B: I want to sen a XML file to the web-service and receive from it too. Thanks in advance
Asked
Active
Viewed 1,166 times
0
-
With webservice do you mean SOAP web service? – rciovati May 16 '12 at 14:04
-
http://stackoverflow.com/questions/1048310/how-to-call-a-net-web-service-from-android – Habib May 16 '12 at 14:23
2 Answers
0
For connecting a website use the following code
URL url = new URL("http://www.myweb.com");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setConnectTimeout(5000); // 5 seconds
conn.setRequestMethod("GET");
conn.connect();
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = rd.readLine()) != null) {
//data of the page will be returned in line, do whatever u want here
}

Raheel
- 4,953
- 4
- 34
- 40
0
i founded this tool to auto generate wsdl to android code,
http://www.wsdl2code.com/Example.aspx
public void callWebService(){
SampleService srv1 = new SampleService();
Request req = new Request();
req.companyId = "1";
req.userName = "userName";
req.password = "pas";
Response response = srv1.ServiceSample(req);
}

Bennya
- 554
- 5
- 10