0

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

Sherif El Nady
  • 527
  • 2
  • 6
  • 15

2 Answers2

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