tags:

views:

210

answers:

1

Hi There,

I have to map a REST Webservice URL like "http://server:8080/application/service/customer/v1" to createCustomer method in CreateCustomerBean class..

I have done the following mappings..

  *Web.xml*
    <servlet-mapping>
    <servlet-name>RestiveServlet</servlet-name>
    <url-pattern>/service/*</url-pattern>
    </servlet-mapping>

*Rest-Config.xml*
<jaxrs:server address="/customer/"
<jaxrs:serviceBean>
<ref bean="CreateCustomerBean"/>
</jaxrs:serviceBean>
</jaxrs:server>

Now the problem is the remaining path of the url("http://server:8080/application/service/customer/v1") is v1 rest all is mapped and i have to specify 2 @Path attributes one at the CreateCustomerBean class level and one at the createCustomer method in that bean.. so i have to append "create" before v1 .. and the url becomes

@Path (/create/)

CreateCustomerBean{

@Path(/v1)

createClient(String request){ }

}

http://server%3A8080/application/service/customer/create/v1/ which i dont want.. is there any way to avoid the @Path attribute at the class level and direct all the request to the createCustomer method.

+1  A: 

In you code you can re-write code like this

@Path ("/v1")

CreateCustomerBean{

@Post
createClient(String request){ }

}

As long as you specify the POST attribute all the post request should be re-directed to the respective method.

Hope it helps. Cheers

Priyank