users@jersey.java.net

Re: [Jersey] entities encoding issues in the response

From: Arul Dhesiaseelan <arul_at_fluxcorp.com>
Date: Mon, 19 May 2008 08:58:58 -0600

Paul,

Here is my custom Stream writer. I just delegate writeCData to
XMLStreamWriter. I will try with a standalone test.

public class MyStreamWriter implements XMLStreamWriter {
  private XMLStreamWriter mImpl;

  public MyStreamWriter(XMLStreamWriter xmlStreamWriter) throws
XMLStreamException {
    this.mImpl = xmlStreamWriter;
  }

  public void writeCData(String s) throws XMLStreamException {
    mImpl.writeCData(s);
  }

  public void writeCharacters(String s) throws XMLStreamException {
    if (shouldUseCData(s)) {
      System.out.println("Using CDATA");
      mImpl.writeCData(s);
    } else {
      mImpl.writeCharacters(s);
    }
  }

  private boolean shouldUseCData(String s) {
    if (s.contains("CDATA")) {
      return true;
    } else return false;
  }
//removed other methods
}

Am I missing something here?

Thanks!
Arul

Paul Sandoz wrote:
> Arul Dhesiaseelan wrote:
>> Paul,
>>
>> Sorry, this error seems to have occurred when the CXF service was
>> down. Now I started both the services and I see this error go away.
>> Lookslike, Jersey is now able to find my custom messagebodywriter.
>>
>> INFO: Provider classes found:
>> class rest.jaxb.CDATAProvider
>>
>> But when I invoke the REST method, I still see this un-encoded CDATA.
>>
>> <cell>&lt;![CDATA[&lt;div class=&quot;progressOuterRow&quot;&gt;&lt;
>> div class=&quot;progressInnerRow&quot; style=&quot;width:
>> 0px;&quot;&gt;&lt;/div
>> &gt;&lt;div class=&quot;progressText&quot;&gt;0/0
>> MB&lt;/div&gt;&lt;/div&gt;]]&g
>> t;</cell>
>>
>> Am I missing something?
>>
>
> It is escaping the CDATA, are you writing the CDATA section
> explicitly? or are you deferring to XMLStreamWriter.writeCData? Can
> you send the wrapper code?
>
> It may be a problem with your XMLStreamWriter method, or it could be a
> bug with the XMLStreamWriter implementation. I recommend writing a
> stand alone test using XMLStreamWriter.writeCData to verify it is
> doing the right thing.
>
> Paul.
>
>> Thanks for all the help.
>>
>> Regards,
>> Arul
>>
>>
>> Paul Sandoz wrote:
>>> Hi Arul,
>>>
>>> That error appears independent of the RESTful service, is that the
>>> case? i.e. this error would be reproducible if you wrote some stand
>>> alone Java code to invoke a CXF JAX-WS Service ?
>>>
>>> More specifically the problem appears to be with the XML document
>>> returned from the CXF JAX-WS Service. The client is having trouble
>>> parsing it, most likely for the reason that Tatu gives.
>>>
>>> Paul.
>>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net