2

I am setting a REST Web Service on a 2.5 Web App on Tomcat 6 using CXF 3.0.2. The webservice receives a POST request with no parameters and returns a JSON String with internationals characters (like é, è, à, ...).

The problem is that the calling application seems to receive the String not encoded in UTF-8. I tried with SoapUI but similar problem with the "RAW View" (the "JSON view" seems OK).

I really don't know what could be the problem. In fact, i don't know if the calling app is not reading in UTF-8 or CXF sends a non UTF-8 encoded response.

Java REST Web Service :

    package test;

    @Path("/TestService")
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON + ";charset=UTF-8")
    public class TestService {

        @Path("/indicateurs")
        @POST
        public String indicateurs() {
            return "iiérrràr_îttt";
        }
    }

cxf-servlet.xml :

    lt;bean id="testService" class="test.TestService"/>
    <jaxrs:server id="testRestService" address="/TestService">
    <jaxrs:serviceBeans>
    <ref bean="testService"/>
    </jaxrs:serviceBeans>
    <jaxrs:providers>
    <bean class="org.apache.cxf.jaxrs.provider.json.JSONProvider">
    <property name="dropRootElement" value="true" />
    <property name="supportUnwrapped" value="true" />
    </bean>
    </jaxrs:providers>
    </jaxrs:server>

SoapUI JSON View :

    iiérrràr_îttt

SoapUI RAW View :

 
    HTTP/1.1 200 OK
    Server: Apache-Coyote/1.1
    Date: Tue, 09 Dec 2014 10:54:52 GMT
    Content-Type: application/json;charset=UTF-8
    Transfer-Encoding: chunked
    Connection: close

    iiérrràr_îttt
1
  • The Producer looks ok, but what is your calling code that fails? Commented Dec 9, 2014 at 11:35

1 Answer 1

2

I managed to find the issue.

As 'luuksen' said, the Producer was OK.

The calling code is a Java middleware using the json-smart library, with has an issue with UTF-8 : https://code.google.com/p/json-smart/issues/detail?id=48.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.