Hello Brent,
I think also you can simplify your client code as follow:
ClientResource pubResource = *new* ClientResource("
http://localhost:8111/pcws/1/card/1111222233334444/NIL/hold");
pubResource.put(*new* StringRepresentation(
"<hold_request><hold_response_code>05</hold_response_code></hold_request>"
));
or even
ClientResource pubResource = *new* ClientResource("
http://localhost:8111/pcws/1/card/1111222233334444/NIL/hold");
pubResource.put(
"<hold_request><hold_response_code>05</hold_response_code></hold_request>",
MediaType.TEXT_PLAIN));
On server side, your are not required to precise the list of variants:
*public* *class* CardHoldResource *extends* ServerResource {
@Put or @Put("txt")
*public* StringRepresentation createHold(String text) {
... //do something
}
}
Could you precise the version of Restlet you are using. Do you think the
path
"pcws/1/card/1111222233334444/NIL/hold<http://localhost:8111/pcws/1/card/1111222233334444/NIL/hold>"
can be caught by another uri template defined by your application?
Best regards,
Thierry Boileau
Hello Brent,
>
> have you tried to annotate your handler with:
>
> @Put("txt")
>
> instead?
>
> On Mon, Jul 18, 2011 at 2:26 PM, Brent Cerrato <[email protected]>
> wrote:
> > My client resource looks like this:
> >
> >
> >
> > Client client = new Client(new Context(), Protocol.HTTP);
> >
> > ClientResource pubResource = new
> > ClientResource("
> http://localhost:8111/pcws/1/card/1111222233334444/NIL/hold");
> >
> > pubResource.setNext(client);
> >
> > pubResource.put(new
> >
> StringRepresentation("<hold_request><hold_response_code>05</hold_response_code></hold_request>"));
> >
> >
> >
> > When I execute that code I get a Method Not Allowed.
> >
> >
> >
> > My resource looks like this:
> >
> >
> >
> > public class CardHoldResource extends ServerResource {
> >
> > public CardHoldResource() {
> >
> > super();
> >
> > getVariants().add(new Variant(MediaType.TEXT_PLAIN));
> >
> > }
> >
> >
> >
> > @Put
> >
> > public StringRepresentation createHold(String text) {
> >
> > ... //do something
> >
> > }
> >
> > }
> >
> >
> >
> >
> >
> >
> >
> > When I override put(Representation,Variant) I do the same instanceof
> check
> > that they do in the source... and it fails the check...
> >
> >
> >
> > What am I doing wrong to allow me to post with just a simple text body?
> >
> >
> >
> > ~brent
> >
> >
>
>
>
> --
> Fabián Mandelbaum
> IS Engineer
>
> ------------------------------------------------------
>
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2798838
>
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2798877