You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Shayanthan Kanaganayagham <sh...@gmail.com> on 2011/09/24 09:20:14 UTC

XML output issue in the CXF soap message body output

I'm developing an CXF web service in ServiceMix 4.2. In the web-service
output need to send an xml output in the body. I created cxf endpoint and
defined the routes to generate the output.
If the result have atleast two child elements under its root tag( CXFOutput
), the output XML will produce in a proper manner in the response soap
message body.
Sample :
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <getCompleteItemNumberResponse xmlns="
http://postmarque.proiam.com/ivrsnumber/ws/domain">
         <OUTPUT><![CDATA[<?xml version=”1.0” encoding=”utf-8” ?>
                <CXFOutput Input_No = “123456789” Record_Count = “2”
Return_Code = “000” Return_Msg = “Success”>
                    < Item_No = “ER123456789SG”/>
                    < Item_No = “EA123456789FR”/>
                </CXFOutput>]]>
        </OUTPUT>
      </getCompleteItemNumberResponse>
   </soap:Body>
</soap:Envelope>

But the result XML will encoded as '&lt;' for '<' in the response soap body
when the root (CXFOutput) have zero child elements.

Sample :
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <getCompleteItemNumberResponse xmlns="
http://postmarque.proiam.com/ivrsnumber/ws/domain">
         <OUTPUT>&lt;![CDATA[&lt;?xml version=”1.0” encoding=”utf-8” ?>
                &lt;CXFOutput Input_No = “123456789” Record_Count = “2”
Return_Code = “000” Return_Msg = “Success”/>]]>
        </OUTPUT>
      </getCompleteItemNumberResponse>
   </soap:Body>
</soap:Envelope>

How can I solve this unwanted encoding problem in the XML output inside the
soap body. I have tried to Intercept the result and try to format the
output, but that also failed.

-- 
"Never Expect Things To Happen. Struggle And Make Them Happen" - NOTHING IS
IMPOSSIBLE.

http://www.shayanth.info/
http://project-eid.org

Re: XML output issue in the CXF soap message body output

Posted by Shayanthan Kanaganayagham <sh...@gmail.com>.
I'm also suspecting with the Camel routing. Camel internally using the CXF
component to create the output. I defined the output as String in WSDL. So,
Internally CXF resolved the webservice output and amend the CDATA section
with the output. But if I have only root element in the constructed XML, it
doesn't amend the CDATA section with XML.

On Tue, Sep 27, 2011 at 1:22 AM, Daniel Kulp <dk...@apache.org> wrote:

>
> This may be an issue with SMX.   Not really sure.
>
> That said, how is the XML for the output being constructed?   Is it a DOM
> tree?   Generic "Source"?   etc.....    Is the content of the OUTPUT
> element a
> "Text" that has a string that contains the CDATA or is it really a CDATA
> node?
>
> It doesn't look like it's something JAXB created as JAXB doesn't generated
> any
> CDATA sections.   Thus, it could just be something with how the XML is
> constructed.
>
> Dan
>
>
> On Saturday, September 24, 2011 3:20:14 PM Shayanthan Kanaganayagham wrote:
> > I'm developing an CXF web service in ServiceMix 4.2. In the web-service
> > output need to send an xml output in the body. I created cxf endpoint and
> > defined the routes to generate the output.
> > If the result have atleast two child elements under its root tag(
> CXFOutput
> > ), the output XML will produce in a proper manner in the response soap
> > message body.
> > Sample :
> > <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
> >    <soap:Body>
> >       <getCompleteItemNumberResponse xmlns="
> > http://postmarque.proiam.com/ivrsnumber/ws/domain">
> >          <OUTPUT><![CDATA[<?xml version=”1.0” encoding=”utf-8” ?>
> >                 <CXFOutput Input_No = “123456789” Record_Count = “2”
> > Return_Code = “000” Return_Msg = “Success”>
> >                     < Item_No = “ER123456789SG”/>
> >                     < Item_No = “EA123456789FR”/>
> >                 </CXFOutput>]]>
> >         </OUTPUT>
> >       </getCompleteItemNumberResponse>
> >    </soap:Body>
> > </soap:Envelope>
> >
> > But the result XML will encoded as '&lt;' for '<' in the response soap
> body
> > when the root (CXFOutput) have zero child elements.
> >
> > Sample :
> > <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
> >    <soap:Body>
> >       <getCompleteItemNumberResponse xmlns="
> > http://postmarque.proiam.com/ivrsnumber/ws/domain">
> >          <OUTPUT>&lt;![CDATA[&lt;?xml version=”1.0” encoding=”utf-8” ?>
> >                 &lt;CXFOutput Input_No = “123456789” Record_Count = “2”
> > Return_Code = “000” Return_Msg = “Success”/>]]>
> >         </OUTPUT>
> >       </getCompleteItemNumberResponse>
> >    </soap:Body>
> > </soap:Envelope>
> >
> > How can I solve this unwanted encoding problem in the XML output inside
> the
> > soap body. I have tried to Intercept the result and try to format the
> > output, but that also failed.
> --
> Daniel Kulp
> dkulp@apache.org
> http://dankulp.com/blog
> Talend - http://www.talend.com
>



-- 
"Never Expect Things To Happen. Struggle And Make Them Happen" - NOTHING IS
IMPOSSIBLE.

http://www.shayanth.info/
http://project-eid.org

Re: XML output issue in the CXF soap message body output

Posted by Daniel Kulp <dk...@apache.org>.
This may be an issue with SMX.   Not really sure.

That said, how is the XML for the output being constructed?   Is it a DOM 
tree?   Generic "Source"?   etc.....    Is the content of the OUTPUT element a 
"Text" that has a string that contains the CDATA or is it really a CDATA node?

It doesn't look like it's something JAXB created as JAXB doesn't generated any 
CDATA sections.   Thus, it could just be something with how the XML is 
constructed.

Dan


On Saturday, September 24, 2011 3:20:14 PM Shayanthan Kanaganayagham wrote:
> I'm developing an CXF web service in ServiceMix 4.2. In the web-service
> output need to send an xml output in the body. I created cxf endpoint and
> defined the routes to generate the output.
> If the result have atleast two child elements under its root tag( CXFOutput
> ), the output XML will produce in a proper manner in the response soap
> message body.
> Sample :
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
>    <soap:Body>
>       <getCompleteItemNumberResponse xmlns="
> http://postmarque.proiam.com/ivrsnumber/ws/domain">
>          <OUTPUT><![CDATA[<?xml version=”1.0” encoding=”utf-8” ?>
>                 <CXFOutput Input_No = “123456789” Record_Count = “2”
> Return_Code = “000” Return_Msg = “Success”>
>                     < Item_No = “ER123456789SG”/>
>                     < Item_No = “EA123456789FR”/>
>                 </CXFOutput>]]>
>         </OUTPUT>
>       </getCompleteItemNumberResponse>
>    </soap:Body>
> </soap:Envelope>
> 
> But the result XML will encoded as '&lt;' for '<' in the response soap body
> when the root (CXFOutput) have zero child elements.
> 
> Sample :
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
>    <soap:Body>
>       <getCompleteItemNumberResponse xmlns="
> http://postmarque.proiam.com/ivrsnumber/ws/domain">
>          <OUTPUT>&lt;![CDATA[&lt;?xml version=”1.0” encoding=”utf-8” ?>
>                 &lt;CXFOutput Input_No = “123456789” Record_Count = “2”
> Return_Code = “000” Return_Msg = “Success”/>]]>
>         </OUTPUT>
>       </getCompleteItemNumberResponse>
>    </soap:Body>
> </soap:Envelope>
> 
> How can I solve this unwanted encoding problem in the XML output inside the
> soap body. I have tried to Intercept the result and try to format the
> output, but that also failed.
-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
Talend - http://www.talend.com