RE: Re: Resource paths with Restlet and Jax Rs

2010-10-01 Thread webpost
Hi Stephan,

sorry for bothering you that often but I just do not get it running. I just 
will exlain my problem a bit more in detail. While sending GET request 
everything concerning a simple GET request works. But sending a request with 
any other method I always get the 405 status code, even I do just  a normal 
POST request with a normal POST parameter. Let me explain it with a small 
example.

My Jax-Rs resource looks like:
...
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.UriInfo;

@Path(blogs)
public class BlogResource extends {
  ...
  @POST
  public String createBlog(@Context UriInfo info) {

return {\result\:\ok\}
  }
  ...
}


My HTML file looks like:

htmlheadtitleREST Web test client/title/head
body
form name=restrequest action=http://localhost:8182/blogs/blogs; 
target=right method=POST
input type=text value=me name=tags
input type=submit value=Submit /
/form
/body
/html

So it should call the POST method with a POST parameter tags=me. But the server 
just returns a 405. And when I enable the method tunneling the server logs just 
that POST is called with a POST parameter method=DELETE but that the POST 
request is not allowed and returns a 405.

To sum it up, I am not able to process a POST request either with nor without a 
parameter. Do I have to allow POST somehow?

 Hi Matthias,
  as I read parts of your master thesis I found the extension issue and that 
  it was done on purpose. So I could have found it by my own. Sorry for 
  bothering you with this.
  But I got another issue, sending parameter with a POST request. When I send 
  parameter with a POST request I just get an 405 - Method not allowed. I 
  searched the internet and found that you have to enable the different 
  methods woth allowPost(). But to do so you have to use Restlet resources 
  from the Restlet version 1.1. But I don't use Restlet 1.1 (did not found 
  such a method for 2.1) and I don't have use Restlet resources at all.
 
  Do I have to enable the POST methods somehow? (sending a POST request 
  without POST parameter works)
 In the JAX-RS extension not.
 allowPost() is for pure Restlet 1.x.
 
 Do you have the problems with post, if you add parameters for the tunnel 
 filter? Maybe the tunnel filter only works on GET requests.
 
 best regards
 Stephan

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


Re: Exception in Applet running in Eclipse

2010-10-01 Thread Stephan Koops
Hi Darin,

do you connect to the same server, where the applet was loaded from? You 
have to use the same name.
Otherwise it is not alowed for security reasons (in Applets)

best regards
 Stephan

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


Re: Resource paths with Restlet and Jax Rs

2010-10-01 Thread Stephan Koops
Hi Matthias,

Maybe the reason is, that their is no parameter in createBlog() to put 
the data in.

Do you stepped thru the code with the debugger? Start at 
JaxRsApplication.handleRequest(..)

best regards
 Stephan

Am 01.10.2010 15:13, schrieb webp...@tigris.org:
 Hi Stephan,

 sorry for bothering you that often but I just do not get it running. I just 
 will exlain my problem a bit more in detail. While sending GET request 
 everything concerning a simple GET request works. But sending a request with 
 any other method I always get the 405 status code, even I do just  a normal 
 POST request with a normal POST parameter. Let me explain it with a small 
 example.

 My Jax-Rs resource looks like:
 ...
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.UriInfo;

 @Path(blogs)
 public class BlogResource extends {
...
@POST
public String createBlog(@Context UriInfo info) {
  
  return {\result\:\ok\}
}
...
 }


 My HTML file looks like:

 htmlheadtitleREST Web test client/title/head
  body
  form name=restrequest action=http://localhost:8182/blogs/blogs; 
 target=right method=POST
  input type=text value=me name=tags
  input type=submit value=Submit /
  /form
  /body
 /html

 So it should call the POST method with a POST parameter tags=me. But the 
 server just returns a 405. And when I enable the method tunneling the server 
 logs just that POST is called with a POST parameter method=DELETE but that 
 the POST request is not allowed and returns a 405.

 To sum it up, I am not able to process a POST request either with nor without 
 a parameter. Do I have to allow POST somehow?

 Hi Matthias,
 as I read parts of your master thesis I found the extension issue and that 
 it was done on purpose. So I could have found it by my own. Sorry for 
 bothering you with this.
 But I got another issue, sending parameter with a POST request. When I send 
 parameter with a POST request I just get an 405 - Method not allowed. I 
 searched the internet and found that you have to enable the different 
 methods woth allowPost(). But to do so you have to use Restlet resources 
 from the Restlet version 1.1. But I don't use Restlet 1.1 (did not found 
 such a method for 2.1) and I don't have use Restlet resources at all.

 Do I have to enable the POST methods somehow? (sending a POST request 
 without POST parameter works)
 In the JAX-RS extension not.
 allowPost() is for pure Restlet 1.x.

 Do you have the problems with post, if you add parameters for the tunnel
 filter? Maybe the tunnel filter only works on GET requests.

 best regards
  Stephan

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


Re: method not found 405 on multipart/form-data post?

2010-10-01 Thread Jonathan Hall
Hi Keith,

Glad you found a temp fix. I'm not sure what the problem is, the 
boundary should be fine. I tested it here with a multipart message and 
it works as expected (and shows the boundary info).

Just to be sure, you are adding the extension to the current Application 
in use?
I am using a 2.1 snapshot, and running Restlet directly, not within a 
servlet, and using the Jetty connector.

In my Application subclass, I simply have:
getMetadataService().addExtension(multipart, 
MediaType.MULTIPART_FORM_DATA,true);

and in my resource:
@Post(multipart)
 public Representation blah(Representation entity) throws 
ResourceException { ... }

To check that your contexts application is using the multipart 
extension, you could try in your resource:

getApplication().getMetadataService().getMediaType(multipart);

which should return multipart/form-data


Jon

On 28/09/10 18:00, Keith Irwin wrote:
 Jonathan--

 That didn't work. I think it's because the Content-Type comes across
 as a unique string each time a request as made. For example:

multipart/form-data; boundary=6068cb2e3a84
multipart/form-data; boundary=eb944e1f8467

 So, I did something similar to the following (in Scala):

val app = new WebApp()
val multi = MediaType.register(multipart/*, file upload)
app.getMetadataService().addExtension(multipart, multi, true)

 in hopes that the wildcard would pick things up. But, alas, it didn't.
 The only thing that works for me is to override the post method and
 then do something like:

if (entity.getMediaType().toString().contains(multipart)) {
  // do parsing here
}

 All of which means that I'm not stuck. Is there some way to
 characterize the media type such that it'll pick up the content-types
 (above) as sent by clients?

 Keith

 On Tue, Sep 28, 2010 at 1:29 AM, Jonathan Halljonrh...@gmail.com  wrote:

 Hi Keith,

 This is all set in org.restlet.service.MetadataService.

 form is a  MediaType.APPLICATION_WWW_FORM , which explains why the
 multipart is returning a 405.
 A multipart (MediaType.MULTIPART_FORM_DATA ) request doesn't seem to
 be in the MetadataService, so you could add your own.

   From your Application: getMetadataService().addExtension(multipart,
 MediaType.MULTIPART_FORM_DATA, true);

 then you can do:

 @Post(multipart)
 ...

 Hope this helps,

 Jon

 On 28/09/10 02:30, Keith Irwin wrote:
  

 On Mon, Sep 27, 2010 at 5:03 PM, Keith Irwinkeith.ir...@gmail.com
 mailto:keith.ir...@gmail.com  wrote:

  Folks--

  Using restlets 2.1 snapshot

  I have a method defined like this:

@Post(form)
public Representation accept(Representation r) {
   ...
}

  When I use the following command line to test:

 curl -v -d foo=bar http://localhost:9000/my/route

  everything works just fine. I'm getting a representation of type
  application/x-www-form-urlencoded, which is what I'd expect.

  However, if I do the following:

curl -v -F foo=bar http://localhost:9000/my/route

  which sends the data as multipart/form-data, I get a 405, Method
  Not Allowed response.


 When I override the post method in my ServerResource subclass and
 print out the media type of the entity, I get the following:

 multipart/form-data; boundary=e5eac570d03e

 rather than just plain old: multipart/form-data, which is what I'd
 expect based on the value of the MediaType.MULTIPART_FORM_DATA object.

 Not sure if this might be the problem.

 Keith


  If I do NOT use the @Post(form), no matter what I do I get the 405.

  I've got the fileupload extensions installed. Is there something
  I'm missing? What token should I include in the @Post annotation?
   multipartform doesn't seem to work.

  Should I downgrade to 2.0?

  Keith



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


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