How to implement easy client with JAXRS library

girlygirl

New member
Hi,

I have created really easy domain class:

-------

Code:
package xxx 

class Step { 
    
    String name 
    String desc 
    String pom 
    
    static constraints = { 
    } 
}

-------

I have installed plugin and generate resources with generate-resources:

-------

Code:
package xxx 

import org.grails.jaxrs.provider.DomainObjectNotFoundException 

class StepResourceService { 

    def create(Step dto) { 
        dto.save() 
    } 

    def read(id) { 
        def obj = Step.get(id) 
        if (!obj) { 
            throw new DomainObjectNotFoundException(Step.class, id) 
        } 
        obj 
    } 

    def readAll() { 
        Step.findAll() 
    } 

    def update(Step dto) { 
        def obj = Step.get(dto.id) 
        if (!obj) { 
            throw new DomainObjectNotFoundException(Step.class, dto.id) 
        } 
        obj.properties = dto.properties 
        obj 
    } 

    void delete(id) { 
        def obj = Step.get(id) 
        if (obj) { 
            obj.delete() 
        } 
    } 
}

-------

I would like to implement easy class, where I will be able to test my methods. Have anyone got a sample of the code ?

I have implemented easy client in perl:

Code:
use REST::Client;
 
 my $client = REST::Client->new();
 $client->GET('http://localhost:8080/xxx/api/step');

 print $client->responseContent();

but it returns:
<p>The requested URL /xxx/api/step was not found on this server.</p>

Something is wrong, but I have no idea why. Please, help if you have some ideas :)
Thank you in advance !
 
Last edited:
Top