thanks!

On Mon, Dec 12, 2011 at 11:29 AM, Sergey Beryozkin <[email protected]> wrote:
> Hi
>
> for JAX-RS you can override the Response in ResponseHandler filter, for
> example:
> if (Response.getEntity() == null) {
>   return response.status(status).entity("<myresponse/>").build();
> }
>
> Cheers, Sergey
>
>
> On 12/12/11 16:10, Miguel Martins Feitosa Filho wrote:
>>
>> Hello CXF Users,
>>
>> If a SEI has annotations of the form:
>>        @GET
>>        @Path(" thepath ")
>>        @WebResult(name = "methodResponseData"")
>>        @XmlElementWrapper(name = "ListOfMethodResponseData")
>>        public MethodResponseData" method() throws MyAppException;
>>
>> how can we treat the the situation where method returns null?
>>
>> With my current cxf-2.5, jdk1.7.0_01 setup the use of null simply
>> outputs an empty string.
>>
>> For REST:
>> If the return of method() is null the xml outputs nothing (zero bytes).
>>
>> For SOAP:
>> If the return of method() is null the xml is simply the soap envelope
>> and wrapper.
>> The wrapper of course appears because I am using the
>> @SOAPBinding(parameterStyle=ParameterStyle.WRAPPED,use=Use.LITERAL)
>> annotation.
>>
>> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";>
>>        <soap:Body>
>>                <MyApp:methodResponse xmlns:MyApp="http://mynamespace/"/>
>>        </soap:Body>
>> </soap:Envelope>
>>
>> When using the wsdl2java client code this works as expected and the
>> return value of the method as created by CXF is null.
>>
>> One solution to treat the null return value would be instead to throw
>> some application exception of the kind ResponseNotFoundException.
>> Another is to return an empty xml tag such as
>> <methodResponseData />
>>
>> This is more desirable than the exception in the case of our application.
>>
>> Question:
>>
>> 1) Is it possible to get
>> REST output of the form:
>> <methodResponseData />
>>
>> and
>>
>> SOAP output of the form:
>> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";>
>>        <soap:Body>
>>                <MyApp:methodResponse xmlns:MyApp="http://mynamespace/";>
>>                         <methodResponseData/>
>>               </MyApp:methodResponse>
>>        </soap:Body>
>> </soap:Envelope>
>>
>> and still have the CXF client return a null method response
>>
>> 2) Is the idea to use an empty xml tag to represent null a bad one
>> such as<methodResponseData/>? Is there a better way to handle this
>> problem?
>>
>> Thank you,
>>
>> Miguel Feitosa
>
>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com

Reply via email to