I have developed a webservice following the below link, however I am unable to get the request parameters from the POST request body.
http://info.appdirect.com/blog/how-to-easily-build-rest-web-services-with-java-spring-and-apache-cxf
I use the Soap UI to invoke the service, with "Post QueryString in Message Body" option checked. So far, I have tried below options, but none seem to work:
Tried MultiValued Map, but the map is always empty.
@POST @Path("/getpostfile/{fileName}") @Produces("application/pdf") @Consumes("application/x-www-form-urlencoded") public Response getPostFile(MultivaluedMap form){...}
Tried @FormParam() & @QueryParam as well, but still the params are null in webservice method.
Tried creating a POJO bean with @XmlRootElement annotation, however this time I get an exception saying "SEVERE: No message body reader has been found for class com.wcc.LoginInfo, ContentType: application/x-www-form-urlencoded". LoginInfo is my bean class with two parameters:
@XmlRootElement public class LoginInfo { String username; String password; ....
Below is the service method:
@POST
@Path("/getpostfile/{fileName}")
@Produces("application/pdf")
@Consumes("application/x-www-form-urlencoded")
public Response getPostFile(LoginInfo logininfo){...}
Below is my cxf-beans.xml file:
<bean .....>
<jaxrs:server id="wccservice" address="/">
<jaxrs:serviceBeans>
<ref bean="wccdocumentservice" />
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="formUrlEncodeProvider" />
</jaxrs:providers>
</jaxrs:server>
<bean id="wccdocumentservice" class="com.wcc.WCCDocumentServiceImpl" />
<bean id="formUrlEncodeProvider" class="org.apache.cxf.jaxrs.provider.FormEncodingProvider" />
<bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.json.JSONProvider">
<property name="marshallAsJaxbElement" value="true" />
</bean>
Any ideas on how to retrieve the POST parameters in request body, in the Webservice method?