I Currently have a RESTFul web Service exposed using CXF. The Method looks like this.
@GET
@Path("/getProfile/{memberno}/{userid}/{channelid}")
@Consumes("application/xml")
public MaintainCustomerProductResponse getUserDetails(
@PathParam("memberno") String membernumber,
@PathParam("userid") String userid,
@PathParam("channelid") String channelid){
//DO Some Logic here.
}
This can be accessed via following URL & on submitting valid data I get response.
http://server.com:8080/UserService/getProfile/{memberno}/{userid}/{channelid}
Question: How can I pass null value for userid
?
If I simple ignore the {userId}
the request is'nt hitting on the server side web service.
Example
http://server.com:8080/UserService/getProfile/1001//1
Note: I'm using SOAPUi
for Testing and without giving userId
value I see following response on SOAPUI
and Request doesn't hit the server.
SOAPUI Response
<data contentType="null" contentLength="0"><![CDATA[]]></data>
The default match of a variable is [^/]+?
(at least one character) you can manually set the match to [^/]*?
and it should also match empty strings.
Just add the format to the userid variable:
@Path("/getProfile/{memberno}/{userid: [^/]*?}/{channelid}")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With