Using CXF 2.4.1, you should be able to add a property named:

"soap.env.ns.map"

which would be a Map<String, String> of ns -> prefix  that would be added to 
the Envelope.   You may also need to add the property:

"disable.outputstream.optimization"  "true"

to disable some optimizations we do that would prevent it from looking at the 
envelope for the prefixes.

I'm not 100% sure that will work, but it's worth trying it.  :-)

Dan





On Thursday, August 04, 2011 3:44:24 PM agus wrote:
> Hi Dan,
> 
> I have the same problem with namespace positioning and repetition.
> I want the namespace declaration to be on top (inside the envelope) not in
> the header and(or) body.
> Also I would like the declaration to only happen once in the envelope, and
> the rest of the element can use prefix to refer to it. After all this is
> what a prefix for.
> 
> Here is what CXF generated:
> 
> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope";>
>       <soap:Header>
>               <ns3:sinfo xmlns:ns3="http://esb.tiaa.org";
>                       
> xmlns:ns2="http://esb.tiaa.org/life-insurance-correspondence-
v1/types"
>                       guid="GUID is: 8888" senderMachine="Sender machine: HP 
> AGUS" 
ping="ping
> is: PING"
>                       appname="application name is: Correspondence message" />
>               <ns3:stats xmlns:ns3="http://esb.tiaa.org";
>                       
> xmlns:ns2="http://esb.tiaa.org/life-insurance-correspondence-
v1/types"
>                       begin="2011-08-04T14:48:59.191-07:00" ms="5" 
> reqSize="10">
>                       <call target="please work" 
begin="2011-08-04T14:48:59.191-07:00"
>                               end="2011-08-04T14:48:59.191-07:00" ms="28" 
> guid="GUID" 
reqSize="78"
>                               respSize="88" />
>               </ns3:stats>
>       </soap:Header>
>       <soap:Body>
>               <ns2:createForms
>                       
> xmlns:ns2="http://esb.tiaa.org/life-insurance-correspondence-
v1/types"
>                       xmlns:ns3="http://esb.tiaa.org";>
>                       <LifeInsuranceCorrespondence>
>                               <TransactionHeader>
>                                       <TransactionID>transaction 
> id</TransactionID>
>                                       <printerName>Printer Name HP resonant 
Printer</printerName>
>                                       <PIN_NPIN>9308</PIN_NPIN>
>                               </TransactionHeader>
>                       </LifeInsuranceCorrespondence>
>               </ns2:createForms>
>       </soap:Body>
> </soap:Envelope>
> 
> 
> This is what I am hoping to get:
> 
> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope";
>      xmlns:ns3="http://esb.tiaa.org";
>      xmlns:ns2="http://esb.tiaa.org/life-insurance-correspondence-v1/types";>
> <soap:Header>
>               <ns3:sinfo
>                       guid="GUID is: 8888" senderMachine="Sender machine: HP 
> AGUS" 
ping="ping
> is: PING"
>                       appname="application name is: Correspondence message" />
>               <ns3:stats
>                       begin="2011-08-04T14:48:59.191-07:00" ms="5" 
> reqSize="10">
>                       <call target="please work" 
begin="2011-08-04T14:48:59.191-07:00"
>                               end="2011-08-04T14:48:59.191-07:00" ms="28" 
> guid="GUID" 
reqSize="78"
>                               respSize="88" />
>               </ns3:stats>
>       </soap:Header>
>       <soap:Body>
>               <ns2:createForms>
>                       <LifeInsuranceCorrespondence>
>                               <TransactionHeader>
>                                       <TransactionID>transaction 
> id</TransactionID>
>                                       <printerName>Printer Name HP resonant 
Printer</printerName>
>                                       <PIN_NPIN>9308</PIN_NPIN>
>                               </TransactionHeader>
>                       </LifeInsuranceCorrespondence>
>               </ns2:createForms>
>       </soap:Body>
> </soap:Envelope>
> 
> 
> 
> FYI I am using CXF 2.4.1 running on JBoss 4.2
> I have spent two days googling without any luck.
> 
> Thank you in advance.
> 
> Agus
> 
> 
> 
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/How-to-customize-namespaces-position-and-pr
> efix-in-CXF-response-tp3423069p4668112.html Sent from the cxf-user mailing
> list archive at Nabble.com.
-- 
Daniel Kulp
[email protected]
http://dankulp.com/blog
Talend - http://www.talend.com

Reply via email to