facebook

Testing a PUT REST WS from browser

  1. MyEclipse Archived
  2.  > 
  3. Web Services
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #311128 Reply

    avishaic
    Member

    I’ve read the tutorial (Developing REST Web Services Tutorial) and everything works great.
    I wanted to create a function that just changes one parameter of the customer class.
    I’ve added another property to customer call Age and added this function

    
    package com.myeclipseide.ws;
    
    import javax.ws.rs.POST;
    import javax.ws.rs.Path;
    import javax.ws.rs.Produces;
    import javax.ws.rs.QueryParam;
    
    import com.sun.jersey.spi.resource.Singleton;
    
    @Produces("application/xml")
    @Path("update")
    @Singleton
    public class UpdateAge {
    
        @POST
        @Path("test")
        @Produces("text/plain")
        public String updateCustAge(@QueryParam("Age") int newAge) {
            //... lots of code
            return "updated";
        }
    }

    How do I test it from a web browser? (not from the firefox add on – that works fine)

    #311129 Reply

    avishaic
    Member

    In order to test from abrowser I created this web page

    <Html>
    <Head>
    <Title> Test REST WS - POST </Title>
    </Head>
    <Body>
    <H1> This is for the RestDemo Update Age function </H1>
    
    <form method=POST action='http://informatserver:8080/RestDemo/services/update/test'>
           <input type="text" size="5" name='Age'><BR> 
           <input type=submit value="Test"> <BR>
    </form>
    
    </Body>
    </Html>

    and it call the function fine but the function parameter: newAge, is always 0

    What am I doing wrong?
    A.

    #311138 Reply

    avishaic
    Member

    Find my bug – it should FormParam and not QueryParam in the function definition.

    A.

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: Testing a PUT REST WS from browser

You must be logged in to post in the forum log in