I am having problems with methods not being allowed when using Restlet (for
the first time) to exchange information in  XML representations between a
client web service and a server web service.

I am using the latest GAE Restlet snapshot.

I am trying to adapt the approach shown at
http://www.restlet.org/documentation/2.0/firstResource to work with XML
representations rather than Web Representations.

My equivalent to the ItemResource class in the firstResource example has the
following method that I intend to have handle PUT requests on the server
side.

    /**
     * Create a fact
     * @param factRepresentation The XML representation of the fact
     */
    @Put
    public void putFact(Representation factRepresentation) {

        getLogger().info("Creating fact " + index);
        if
(MediaType.APPLICATION_XML.equals(factRepresentation.getMediaType())) {
            DomRepresentation domRepresentation = new
DomRepresentation(factRepresentation);
                            // Do the storing of the new fact here... I am
using the GAE data store to do this.
        }
    }

The server starts and runs nicely at http://localhost:8888/
The Restlet application routes requests to
http://localhost:8888/fact/{index} to this ServerResource.

I have set up the client side to issue the PUT requests as follows:

            String NAMESPACE = "http://my.example.com/";;
            DomRepresentation representation = new
DomRepresentation(MediaType.TEXT_XML);
            Document document = representation.getDocument();
            Element root = document.createElementNS(NAMESPACE,"facts");
            document.appendChild(root);
            Element child = document.createElementNS(NAMESPACE,"fact");
            child.setAttribute("index", "index_1");
            root.appendChild(child);
            return representation;

            Client client = new Client(new Context(), Protocol.HTTP);
            ClientResource factResource = new ClientResource("
http://localhost:8888/fact/"; + index);
            factResource.setNext(client);
            factResource.put(getFactRepresentation(index));

Running that code generates an error where the server resource appears to
inform the client resource that the PUT method is not allowed.

Method Not Allowed (405) - Method Not Allowed
        org.restlet.resource.ClientResource.put(ClientResource.java:1097)


My understanding was that the @Put annotation on the putFact method was
supposed to allow using the PUT method.  Somehow that is not sufficient.

Any pointers to relevant documentation or things that I should try to do
differently would be very helpful in getting started.

Kind regards

Geoff Shuetrim

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

Reply via email to