Re: Re: Android Client/GAE Server - 400 Bad Request

2012-11-22 Thread Thierry Boileau
Hi,

that's fine! I didn't notice that the @Get and @Delete methods where using
parameters.
In the Restlet framework, the parameter correspond to the entity of the
request. The other parameters located in the path or the query of the
URIs are, well, located in the URI and are part of the identification of
the resource.

Best regards,
Thierry Boileau

The problem is finally resolved!
 As i mentioned before in the previous release it was working, but after
 upgrading the app to the new Android platform and foundations, it stopped
 working. I didn't mention it, but only one method works

 @Put
 public void store(SafeNote note);
 Two other method are not working where i tried to send parameter.

 So, the solution was in interface class to remove parameter
 @Get
 public NoteList retrieve(); // see the original code in question.
 @Delete
 public void remove();  // see the original code in question.


 Second place to fix is this method implementation invocation: noteList =
 noteResource.retrieve(); // since i send parameter using URL template.(Same
 fix is for delete method).

 P.S. Thank you Thierry for your attention

 --

 http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=3029139


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

RE: Re: Android Client/GAE Server - 400 Bad Request

2012-11-18 Thread Alon
The problem is finally resolved! 
As i mentioned before in the previous release it was working, but after 
upgrading the app to the new Android platform and foundations, it stopped 
working. I didn't mention it, but only one method works

@Put
public void store(SafeNote note);
Two other method are not working where i tried to send parameter.

So, the solution was in interface class to remove parameter 
@Get 
public NoteList retrieve(); // see the original code in question. 
@Delete
public void remove();  // see the original code in question. 


Second place to fix is this method implementation invocation: noteList = 
noteResource.retrieve(); // since i send parameter using URL template.(Same fix 
is for delete method).

P.S. Thank you Thierry for your attention

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


Re: Android Client/GAE Server - 400 Bad Request

2012-11-15 Thread Thierry Boileau
Hello,

does it stop working only for PUT requests? In this case, this is due to an
issue with GAE (cf
http://wiki.restlet.org/docs_2.1/13-restlet/21-restlet/318-restlet/303-restlet.html
).
Resltet 2.1 proposes a fix for that :

GAE doesn't support HTTP chunked encoding, therefore serialized object
can't be sent (via POST or PUT) to a GAE server. In Restlet Framework
version 2.1 M4 we have a workaround available that buffers the HTTP entity
to prevent chunk encoding. To use it, call the
ClientResource#setRequestEntityBuffering(boolean) method with a true
value. Note that this workaround isn't required for the GWT edition.


Best regards,
Thierry Boileau

Hi,

 I had some working application
 Android/GWT client and GAE server. After upgrading my android version on
 my smartphone the android client stopped working however GWT still working
 until now.
 I used last production version(GWT/GAE/Restlet) that was distributed more
 than 2 years ago.

 Today i would like to fix the problem in Android client, but i get 400 Bad
 Request.
 I went over many documentation, forums, discussions, migration from
 restlet 1 to 2 with many possible solution, but nothing didn't work for me.

 Please find below my code and i will appreciate if you can point me to the
 resolution or can i try to make it working. Let me know if you need more
 information of my app. Thank you!

 Current versions:
 Restlet: 2.0.15
 GAE: 1.7.3
 GWT: 2.4


 
 ANDROID CLIENT:

 public interface NoteResource
 {
 @Get
 public NoteList retrieve(String userID);

 @Put
 public void store(SafeNote note);

 @Delete
 public void remove(String noteID);
 }

 Some code from the main class where i do invocation of the method
 Engine.getInstance().getRegisteredClients().clear();
 Engine.getInstance().getRegisteredClients().add(new
 org.restlet.ext.net.HttpClientHelper(null));
 ClientResource clientResource = new ClientResource(
 http://someapp.appspot/note/get/; + userID);
 noteResource = clientResource.wrap(NoteResource.class);
 noteList = noteResource.retrieve(signedUser);


 **

 GAE SERVER

 public class NoteApplication extends Application
 {
 private static final Logger logger =
 Logger.getLogger(NoteApplication.class.getName());

 /**
  * When launched as a standalone application.
  *
  * @param args
  * @throws Exception
  */
 public static void main(String[] args) throws Exception {
 Component component = new Component();
 component.getClients().add(Protocol.FILE);
 component.getServers().add(Protocol.HTTP, 8080);
 component.getDefaultHost().attach(new NoteApplication());
 component.start();
 }

 @Override
 public synchronized Restlet createInboundRoot() {
 Router router = new Router(getContext());
   getConnectorService().getClientProtocols().add(Protocol.FILE);
 // Serve the files generated by the GWT compilation step.
 File warDir = new File();
 if (!war.equals(warDir.getName())) {
 warDir = new File(warDir, war/);
 }

 Directory dir = new Directory(getContext(),
 LocalReference.createFileReference(warDir));
 router.attachDefault(dir);
 router.attach(/note, NoteResourceImpl.class);
 router.attach(/note/login, NoteResourceImpl.class);
 TemplateRoute routeGet = router.attach(/note/get/{userID},
 NoteResourceImpl.class);
 TemplateRoute routeDelete = router.attach(/note/delete/{NoteID},
 NoteResourceImpl.class);
 MapString, Variable routeVariables =
 routeGet.getTemplate().getVariables();
 routeVariables.put(userID, new
 Variable(Variable.TYPE_URI_QUERY_PARAM));
 routeVariables = routeDelete.getTemplate().getVariables();
 routeVariables.put(safeNoteID, new
 Variable(Variable.TYPE_URI_QUERY_PARAM));
 return router;

 --

 http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=3027743


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