Getting 405 "Method Not Allowed" error using POST with @FormParam (Java web service with Jersey REST) -


i know not easy pass rest server (resource) neither string nor simple type.
simple ordering process need send list of articles (which shall ordered) client teh server.

i tried using "queryparam", converting object (i wrapped list dto) json-string , passing it. didn't work. (but other methods don't need pass object server service works fine, post methods.)

then found out @formparam can theoretically transfer every kind of object. (that's read, true?)

so tried in simple test method pass list of strings service, serverside should give number of elements of list.

that's code:

on server-side (resource):

@path("bestellung") public class bestellungresource {    @path("test")   @post   @consumes(mediatype.application_form_urlencoded)   @produces(xml)    public integer test(     @formparam("list") list<string> list){        return list.size();           } } 


and on client side (in session bean):

public integer  test() {      list<string> list = new arraylist<string>();     list.add("1");     list.add("2");     list.add("3");      form form = new form();     form.add("list", list);      return service              .path("bestellung")              .path("test")              .type(mediatype.application_form_urlencoded)              .post(integer.class, form); } 

where service built that:

clientconfig config = new defaultclientconfig(); client client = client.create(config); service = client.resource(uribuilder.fromuri("<service url>").build()); 

invoking client method gui or directly via ejb explorer gives 405 error.

where's problem? did miss post, mime types or form?

by way, simple form parameters string or int not work , throws 405 error well.

thanks help!
jana

okay.

due fact found reason of 405 error, i'll close question. i'll open new 1 new found misstake of 400 error. explained "solution" in comment above:

i moved service older server (where post didn't work @ , threw 405) newer one, , didn't change service-url in client! @_@ (so new client still tried reach old server)

now, can send list of strings, none of own class objects (entities or dtos). i'm getting http 400 error "bad request". :-( didn't change else. isn't possible send not-standard-types?

(--> i'll ask in new question.)

sorry silly misstake.
jana


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -