If I can acess my web service trough this link what should the String
in the httpget constructior be?
i have the following but i always get an axception and its alwas an
Unknown error. This is calling a .NET web service in my local
machine.


HttpClient client = new DefaultHttpClient();
         HttpGet get = new HttpGet("http://172.17.1.132/WSAndroidTest3/
Service.asmx/HelloWorld");
         try {


                 HttpResponse httpResponse = client.execute(get);

The error comes up in the cliente.execute(get);

Thanks in advance for the help.



On Aug 22, 2:05 pm, "Megha Joshi" <[EMAIL PROTECTED]> wrote:
> You were on the right track in porting your code...I updated the rest of
> your code to work with the new Http library...hope this helps!
>
>         HttpClient client = new DefaultHttpClient();
>         HttpGet get = new
> HttpGet("http://www.biocol.org/json/fetch/lsid/urn:lsid:biocol.org:
> col:15670");
>         try {
>
>                 HttpResponse httpResponse = client.execute(get);
>                 String res="";
>                 if(httpResponse.getStatusLine().getStatusCode()!=404){
>                         res= EntityUtils.toString(httpResponse.getEntity());
> //
>
>                         String temp = res.substring(9);
>                         temp = temp.replace(")", "");
>                         JSONArray jarray = new JSONArray(temp);
>                         int i=0;
>                         String key="";
>                         JSONObject objs = new JSONObject();
>                         objs = jarray.getJSONObject(i);
>                         key=objs.getString("size");
>                         uname.setText(temp);
>                 }else
>
>                 uname.setText("nothing found");
>         }
>         catch (Exception e) {
>                 //Log.e("Error:",e.getMessage());
>                 uname.setText("fault: "+e.getLocalizedMessage());
>         }
>         finally {
>                 get.abort();
>                 get=null;
>         }
>
>
>
> On Fri, Aug 22, 2008 at 12:47 AM, Baran <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > I have this code that was running successfully on m5 SDK. Now I need
> > to port the same to SDK 0.9.
>
> > Till now I have successfully called the web service, but now sure how
> > to proceed further...the codes are as below:
>
> > On SDK m5
> >        HttpClient client = new HttpClient();
> >        GetMethod get = new GetMethod("http://www.biocol.org/json/
> > fetch/lsid/urn:lsid:biocol.org:col:15670<http://www.biocol.org/json/fetch/lsid/urn:lsid:biocol.org:col:15670>
> > ");
> >        try {
> >                int status = client.executeMethod(get);
> >                String res="";
> >                if(status!=404){
> >                        res=get.getResponseBodyAsString(); //
> > uname.setText("m here"+status+res);
> >                        String temp = res.substring(9);
> >                        temp = temp.replace(")", "");
> >                        JSONArray jarray = new JSONArray(temp);
> >                        int i=0;
> >                        String key="";
> >                        JSONObject objs = new JSONObject();
> >                        objs = jarray.getJSONObject(i);
> >                        key=objs.getString("size");
> >                        uname.setText(temp);
> >                }else
>
> >                uname.setText("nothing found");
> >        }
> >        catch (Exception e) {
> >                //Log.e("Error:",e.getMessage());
> >                uname.setText("fault: "+e.getLocalizedMessage());
> >        }
> >        finally {
> >                get.releaseConnection();
> >                get=null;
> >        }
>
> > And on SDK 0.9
>
> >                  DefaultHttpClient client= new DefaultHttpClient();
>
> >              HttpGet get = new HttpGet("http://www.biocol.org/json/
> > fetch/lsid/urn:lsid:biocol.org:col:15670<http://www.biocol.org/json/fetch/lsid/urn:lsid:biocol.org:col:15670>
> > ");
> >              HttpResponse resp;
>
> >              resp = client.execute(get);
>
> > I am not sure about where they have moved the API methods and how to
> > retrieve the output as string so that I can parse it using JSON...
>
> > Any help would be great- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new Android 0.9 SDK beta!
http://android-developers.blogspot.com/2008/08/announcing-beta-release-of-android-sdk.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to