Hi Sergey,
This is for form based submission.
Below is a snippet of my code. I want to be able to accept non-ASCII
characters in "message" parameter below. However, when I tested with
Chinese characters, they are converted to "?" as shown in my logs.
Any help will be very much appreciated.
@POST
// @Consumes("application/x-www-form-urlencoded")
public SMSSendSmsResponse sendSms(@HeaderParam("Authorization")
String authorization,
@Context MessageContext mc,
@FormParam("address") List<String> address,
@FormParam("message") String message,
@FormParam("notifyURL") String notifyURL,
@FormParam("correlator") String
correlator,
@FormParam("senderName") String
senderName,
@FormParam("Charging") String Charging)
throws MalformedURLException, PolicyException, ServiceException {
if (address != null) {
for (Iterator<String> i = address.iterator(); i.hasNext();) {
log.info("Address: " + i.next());
}
}
log.info("Message: " + message);
log.info("Notify URL: " + notifyURL);
log.info("Correlator: " + correlator);
log.info("Sender Name: " + senderName);
log.info("Charging: " + Charging);
....
}
regards,
Loh Kok Jeng
On 24 June 2010 02:00, Sergey Beryozkin <[email protected]> wrote:
> I need to know the details of the request and how a resource method
> expecting the values looks like
>
> thanks, Sergey
>
> On Tue, Jun 22, 2010 at 7:10 PM, Rakesh Rai <[email protected]> wrote:
>
>> This is the method that does the trick.... converts to UTF-8 and transforms
>> to UTF-8 format string and sends it back to the caller
>> Wherever in your service class / action class add this method and convert
>> the existing string to return the UTF-8 transformed string / text
>> /**
>> *
>> * @param utfEightString
>> * @return String converted to USF-8 format and send it to the caller .
>> * @throws java.io.
>> UnsupportedEncodingException
>> */
>> public static final String utfEightConvert(String utfEightString)
>> throws java.io.UnsupportedEncodingException {
>>
>> byte[] bytes = new byte[utfEightString.length()];
>> for (int i = 0; i < utfEightString.length(); i++) {
>> bytes[i] = (byte) utfEightString.charAt(i);
>> }
>> return new String(bytes, "UTF-8");
>>
>> }
>>
>> Hope it helps.
>> Rakesh
>>
>>
>> On Tue, Jun 22, 2010 at 1:47 PM, Sergey Beryozkin <[email protected]
>> >wrote:
>>
>> > Is it a form based submission ? or XML is posted in the body ?
>> >
>> >
>> > cheers, Sergey
>> >
>> > On Mon, Jun 21, 2010 at 6:00 PM, Loh Kok Jeng <[email protected]>
>> > wrote:
>> >
>> > > Dear all,
>> > >
>> > > I'm struggling with non-ASCII characters passed in request params of a
>> > > REST service. The characters become ? when received by my app
>> > > developed using CXF. The encoding is set to UTF-8 by the REST client.
>> > > Why do I get "?"?
>> > >
>> > > Thanks in advance.
>> > >
>> >
>>
>