I have this code to get a RESTFul resource

public String loadResourceString() 
{   
    Reference ref = new Reference("http://192.0.0.1:8080/op/op2";);
    ClientResource resource = new ClientResource(ref);

    Form paramsPost = new Form();
    paramsPost.add("Id", "ABCD");
    paramsPost.add("code", "2");
    Representation representation = paramsPost.getWebRepresentation();

    representation.setCharacterSet(CharacterSet.UTF_8);
    Representation result = resource.post(representation);
    String sResult = "";
    try
    {
        sResult = result.getText();
    } catch (IOException e)
    {
        return ("IOException ");
    }

    return ("Return \n" + sResult + "\n");
}
I have this code attached with a button and it works ok a lot of times but 
sometimes the result is null. I don't understand the reason.

If I use this code on a Java application in a PC inside a LAN it works ok 
always. 
If I use this code on a Android application in a tablet inside a WLAN it fails 
frequently. If I use GET instead of POST it works better but still fails 
sometimes.

Can someone help me?
Thanks

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2909348

Reply via email to