Hi
Default FormEncodingProvider will not be able to inject a sequence of
name/value pairs into a bean.
So your original idea of sending a JSON payload kind of works, except
that JSONProvider does not understand a form media type.
Let me summarize the options:
- send JSON payload as before, with a form format, and then change a
content-type on a server to 'application/json'
- send JSON payload as before, with a form format, and configure
JSONProvider to accept a form format, see
http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/resources/jaxrs/WEB-INF/beans.xml
(search for a bean named 'jsonProvider', 'consumeMediaTypes' property)
will work in this case, but will affect name/value payloads
- have a Form or MultivaluedMap parameter instead of AmountTransaction
and populate AmountTransaction manually
- have a custom provider (as you suggested)
- use a cxf extension @FormParam("") with AmountTransaction
- use JAX-RS 2.0 @BeanParam and have AmountTransaction properties
annotated with FormParam
Plenty of options :-), hope one of them will work for you
Sergey
On 09/07/13 07:31, dilunika wrote:
Hi Sergey,
But when I send content with form-url-encoded type, still I am getting the
same error. Do, I need to implement a un-marshaller to convert body content
to my Data Structure (AmountTransaction) ?
Part of Log:
=========
ID: 17
Address:
http://cnb69:8181/cxf/paymentsandbox/2_1/payment/tel:+916309700000/transactions/amount
Encoding: ISO-8859-1
Http-Method: POST
Content-Type: application/x-www-form-urlencoded
Headers: {Accept=[application/json], accept-encoding=[gzip,deflate],
Authorization=[Basic a2FzdW5wYXlzYW5kYm94OnBANTV3MHJk],
connection=[keep-alive], Content-Length=[267],
content-type=[application/x-www-form-urlencoded], Host=[cnb69:8181],
User-Agent=[Apache-HttpClient/4.1.1 (java 1.5)]}
Payload: clientCorrelator=54321&
endUserId=tel%3A%2B16309700001&
amount=10.00&
currency=USD&
description=Alien%20Invaders%20Game&
onBehalfOf=Example%20Games%20Inc&
purchaseCategoryCode=Game&
channel=SMS&
taxAmount=0&
referenceCode=REF-12345&
transactionOperationStatus=CHARGED
--------------------------------------
2013-07-09 11:45:37,607 | WARN | qtp1025922771-224 |
org.apache.cxf.jaxrs.utils.JAXRSUtils | No message body reader has been
found for request class AmountTransaction, ContentType :
application/x-www-form-urlencoded.
2013-07-09 11:45:37,608 | INFO | qtp1025922771-224 |
org.apache.cxf.interceptor.AbstractLoggingInterceptor | Outbound Message
---------------------------
ID: 17
Response-Code: 415
Content-Type: text/xml
Headers: {Date=[Tue, 09 Jul 2013 06:15:37 GMT], Content-Length=[0]}
--------------------------------------
--
View this message in context:
http://cxf.547215.n5.nabble.com/Consume-application-x-www-form-urlencoded-Content-Type-in-REST-Web-Service-cxf-rsServer-tp5730399p5730450.html
Sent from the cxf-user mailing list archive at Nabble.com.
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com