You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Gaurav Chandna <ga...@gmail.com> on 2013/09/10 09:19:02 UTC

Issue in Prefix management of namespace in cxf-2.5.10

Hi ,

I am using cxf-2.5.10 and using xmlbeans for generating java objects.
I am facing following issue w.r.t. prefix management, the prefixes declared
in envelope or in soap body section are not being used and entire namespace
is getting copied for all the elements:

*Expected Result*:
<SOAP-ENV:Envelope 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:esl="http://www.cvscaremark.com/esl/entities/1_0" 
xmlns:eldm="http://www.cvscaremark.com/esl/eldm/entities/1_0">
<SOAP-ENV:Body>
<p:PatientDURProfileRequest
xmlns:p="http://www.cvscaremark.com/esl/isp/messages/1_0">
  <esl:AppMsgID>******</esl:AppMsgID>
  <esl:Version>1.0</esl:Version>
  <esl:MsgDateTimestamp>*******</esl:MsgDateTimestamp>
  <p:sourceSystemID>
    <eldm:sourceSystemName>*******</eldm:sourceSystemName>
    <eldm:sourceSystemKey KeyName="PatientIdentifier">
      <eldm:KeyValue>*******</eldm:KeyValue>
    </eldm:sourceSystemKey>
    <eldm:effectiveDate>*******</eldm:effectiveDate>
    <eldm:termDate>*******</eldm:termDate>
  </p:sourceSystemID>
  <p:startDate>*******</p:startDate>
  <p:endDate>*******</p:endDate>
  <p:lineOfBusinessCode>*******</p:lineOfBusinessCode>
</p:PatientDURProfileRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>



*Actual Result:*
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:ns3="http://www.cvscaremark.com/esl/entities/1_0"
 xmlns:ns2="http://www.cvscaremark.com/esl/isp/messages/1_0">
<soap:Body>
   <PatientDURProfileRequest
xmlns="http://www.cvscaremark.com/esl/isp/messages/1_0">
   <AppMsgID
xmlns="http://www.cvscaremark.com/esl/entities/1_0">*****</AppMsgID>
    <MsgDateTimestamp
xmlns="http://www.cvscaremark.com/esl/entities/1_0">*****</MsgDateTimestamp><sourceSystemID>
	<sourceSystemName
xmlns="http://www.cvscaremark.com/esl/eldm/entities/1_0">******</sourceSystemName>
<sourceSystemKey xmlns="http://www.cvscaremark.com/esl/eldm/entities/1_0" 
PatientIdentifier">
	<KeyValue>******</KeyValue>
	            </sourceSystemKey>
                 </sourceSystemID>
              </PatientDURProfileRequest>
            </soap:Body>
</soap:Envelope>



I have tried following options to resolve the same but no success has been
acheived:
1. XMLOptions - not working
2. Adding namespace in "soap.env.ns.map" using cxf.xml and also using
interceptor

Please provide the solution, if anyone has faced the sae issue



--
View this message in context: http://cxf.547215.n5.nabble.com/Issue-in-Prefix-management-of-namespace-in-cxf-2-5-10-tp5733766.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Issue in Prefix management of namespace in cxf-2.5.10

Posted by Aki Yoshida <el...@gmail.com>.
Hi Gaurav,
2013/9/19 Gaurav Chandna <ga...@gmail.com>:
> Hi Aki,
>
> I was exploring more on this issue and following are the findings:
>
> 1. If xmlbeans are used for generating java binding objects the all the java
> objects generated have prefix element missing in QName constructor such as:
>   private static final javax.xml.namespace.QName LASTACTIVITYDATE$0 =
>         new
> javax.xml.namespace.QName*("http://www.cvscaremark.com/esl/eldm/entities/1_0",
> "lastActivityDate");*
>
> 2. Because of missing prefix in the QName Constructor in Java binding
> objects below mentioned changes are done in mentioned file gave desired
> result - DatawriterImpl used for  xmlbeans -
> private static void writeStartElement(XMLStreamReader reader,XMLStreamWriter
> writer) throws XMLStreamException {
>  if (uri != null) {
>   writeElementNS = true;
>   Iterator<String> it =
> CastUtils.cast(writer.getNamespaceContext().getPrefixes(uri));
>   while (it != null && it.hasNext()) {
>     String s = it.next();
>     if (s == null) {
>         s = "";
> }
>  *// Changes to override the default behaviour to write the namespace
>   else {
>    prefix = s;
>    writeElementNS = false;
>   }
>  /** if (s.equals(prefix)) { writeElementNS = false; }*/
>  // Changes to override the default behaviour to write the namespace*                   }
>                 }
>         }
>

I added an option to get certain namespace declarations excluded from
being serialized for jaxb's databinding.
But I haven't looked at xmlbeans' databinding to see if there is a
similar possibility.

>
> 3. I have tried soap.env.ns map, it is also not working - It has included
> all the declared nsmap in soap header segment but in the soap body its not
> replacing namespaces with prefix.

This property works for the envelope part but not for the inside the bean.

>
> 4. I have tried StaxTransform feature for outtransfor elements which is
> giving partial success of dropping complete repeated namespace from soap
> body but not appending the namespace prefix before the element.
>

if you have figured out using the stax transform feature and the only
missing piece is the lack of the prefix for the namespace, there is
potentially a way. The stax transform feature keeps the original
prefix to maintain the qname linking (the original prefix may be used
in some of the QName attribute types). But in your case, setting the
default namespace to another arbitrary uri, your original namespace
may be prefixed. not sure about this, but worth a try. see
http://cxf.apache.org/docs/transformationfeature.html#TransformationFeature-Defaultnamespaceontheoutput

regards, aki

> Your help will be much appreciated!!!
> Being a newbie to CXF, I might be in wrong direction....request you to
> please provide right solution for same.
>
>
> -
> Gaurav
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Issue-in-Prefix-management-of-namespace-in-cxf-2-5-10-tp5733766p5734258.html
> Sent from the cxf-user mailing list archive at Nabble.com.

Re: Issue in Prefix management of namespace in cxf-2.5.10

Posted by Gaurav Chandna <ga...@gmail.com>.
Hi Aki,

I was exploring more on this issue and following are the findings:

1. If xmlbeans are used for generating java binding objects the all the java
objects generated have prefix element missing in QName constructor such as:
  private static final javax.xml.namespace.QName LASTACTIVITYDATE$0 = 
        new
javax.xml.namespace.QName*("http://www.cvscaremark.com/esl/eldm/entities/1_0",
"lastActivityDate");*

2. Because of missing prefix in the QName Constructor in Java binding
objects below mentioned changes are done in mentioned file gave desired
result - DatawriterImpl used for  xmlbeans - 
private static void writeStartElement(XMLStreamReader reader,XMLStreamWriter
writer) throws XMLStreamException {
 if (uri != null) {
  writeElementNS = true;
  Iterator<String> it =
CastUtils.cast(writer.getNamespaceContext().getPrefixes(uri));
  while (it != null && it.hasNext()) {
    String s = it.next();
    if (s == null) {
	s = "";
}
 *// Changes to override the default behaviour to write the namespace
  else {
   prefix = s;
   writeElementNS = false;
  }
 /** if (s.equals(prefix)) { writeElementNS = false; }*/
 // Changes to override the default behaviour to write the namespace*			}
		}
	}


3. I have tried soap.env.ns map, it is also not working - It has included
all the declared nsmap in soap header segment but in the soap body its not
replacing namespaces with prefix.

4. I have tried StaxTransform feature for outtransfor elements which is
giving partial success of dropping complete repeated namespace from soap
body but not appending the namespace prefix before the element.

Your help will be much appreciated!!! 
Being a newbie to CXF, I might be in wrong direction....request you to
please provide right solution for same.


-
Gaurav



--
View this message in context: http://cxf.547215.n5.nabble.com/Issue-in-Prefix-management-of-namespace-in-cxf-2-5-10-tp5733766p5734258.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Issue in Prefix management of namespace in cxf-2.5.10

Posted by Aki Yoshida <el...@gmail.com>.
For jaxb, I think setting soap.env.ns.map won't help, as this property
doesn't influence how its marshaller is set up.

To influence jaxb's namespace handling, you can set the jaxb
marshaller's property com.sun.xml.bind.namespacePrefixMapper with your
own prefix mapper. But this requires writing a code. So I think we
should provide a simpler way. cxf's jaxb binding configuration already
provides the namespace mapping option that sets the above prefix
mapper. However, this mapper currently only influences the namespace
prefix mapping itself. So we should add an option to configure the
contextual namespace mapping so that one can specify the namespace
declarations inherited from outside. I'll take a look.


2013/9/15 Andrei Shakirin <as...@talend.com>:
> Hi Gaurav,
>
> I guess that soap.env.ns.map was supported in later CXF releases.
> Could you try 2.7.X?
>
> Regards,
> Andrei.
>
>> -----Original Message-----
>> From: Gaurav Chandna [mailto:gaurav.chandna02@gmail.com]
>> Sent: Dienstag, 10. September 2013 09:19
>> To: users@cxf.apache.org
>> Subject: Issue in Prefix management of namespace in cxf-2.5.10
>>
>> Hi ,
>>
>> I am using cxf-2.5.10 and using xmlbeans for generating java objects.
>> I am facing following issue w.r.t. prefix management, the prefixes declared in
>> envelope or in soap body section are not being used and entire namespace is
>> getting copied for all the elements:
>>
>> *Expected Result*:
>> <SOAP-ENV:Envelope
>> xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
>> xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>> xmlns:esl="http://www.cvscaremark.com/esl/entities/1_0"
>> xmlns:eldm="http://www.cvscaremark.com/esl/eldm/entities/1_0">
>> <SOAP-ENV:Body>
>> <p:PatientDURProfileRequest
>> xmlns:p="http://www.cvscaremark.com/esl/isp/messages/1_0">
>>   <esl:AppMsgID>******</esl:AppMsgID>
>>   <esl:Version>1.0</esl:Version>
>>   <esl:MsgDateTimestamp>*******</esl:MsgDateTimestamp>
>>   <p:sourceSystemID>
>>     <eldm:sourceSystemName>*******</eldm:sourceSystemName>
>>     <eldm:sourceSystemKey KeyName="PatientIdentifier">
>>       <eldm:KeyValue>*******</eldm:KeyValue>
>>     </eldm:sourceSystemKey>
>>     <eldm:effectiveDate>*******</eldm:effectiveDate>
>>     <eldm:termDate>*******</eldm:termDate>
>>   </p:sourceSystemID>
>>   <p:startDate>*******</p:startDate>
>>   <p:endDate>*******</p:endDate>
>>   <p:lineOfBusinessCode>*******</p:lineOfBusinessCode>
>> </p:PatientDURProfileRequest>
>> </SOAP-ENV:Body>
>> </SOAP-ENV:Envelope>
>>
>>
>>
>> *Actual Result:*
>> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
>> xmlns:ns3="http://www.cvscaremark.com/esl/entities/1_0"
>>  xmlns:ns2="http://www.cvscaremark.com/esl/isp/messages/1_0">
>> <soap:Body>
>>    <PatientDURProfileRequest
>> xmlns="http://www.cvscaremark.com/esl/isp/messages/1_0">
>>    <AppMsgID
>> xmlns="http://www.cvscaremark.com/esl/entities/1_0">*****</AppMsgID
>> >
>>     <MsgDateTimestamp
>> xmlns="http://www.cvscaremark.com/esl/entities/1_0">*****</MsgDateT
>> imestamp><sourceSystemID>
>>       <sourceSystemName
>> xmlns="http://www.cvscaremark.com/esl/eldm/entities/1_0">******</so
>> urceSystemName>
>> <sourceSystemKey
>> xmlns="http://www.cvscaremark.com/esl/eldm/entities/1_0"
>> PatientIdentifier">
>>       <KeyValue>******</KeyValue>
>>                   </sourceSystemKey>
>>                  </sourceSystemID>
>>               </PatientDURProfileRequest>
>>             </soap:Body>
>> </soap:Envelope>
>>
>>
>>
>> I have tried following options to resolve the same but no success has been
>> acheived:
>> 1. XMLOptions - not working
>> 2. Adding namespace in "soap.env.ns.map" using cxf.xml and also using
>> interceptor
>>
>> Please provide the solution, if anyone has faced the sae issue
>>
>>
>>
>> --
>> View this message in context: http://cxf.547215.n5.nabble.com/Issue-in-
>> Prefix-management-of-namespace-in-cxf-2-5-10-tp5733766.html
>> Sent from the cxf-user mailing list archive at Nabble.com.

RE: Issue in Prefix management of namespace in cxf-2.5.10

Posted by Andrei Shakirin <as...@talend.com>.
Hi Gaurav,

I guess that soap.env.ns.map was supported in later CXF releases.
Could you try 2.7.X?

Regards,
Andrei.

> -----Original Message-----
> From: Gaurav Chandna [mailto:gaurav.chandna02@gmail.com]
> Sent: Dienstag, 10. September 2013 09:19
> To: users@cxf.apache.org
> Subject: Issue in Prefix management of namespace in cxf-2.5.10
> 
> Hi ,
> 
> I am using cxf-2.5.10 and using xmlbeans for generating java objects.
> I am facing following issue w.r.t. prefix management, the prefixes declared in
> envelope or in soap body section are not being used and entire namespace is
> getting copied for all the elements:
> 
> *Expected Result*:
> <SOAP-ENV:Envelope
> xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:esl="http://www.cvscaremark.com/esl/entities/1_0"
> xmlns:eldm="http://www.cvscaremark.com/esl/eldm/entities/1_0">
> <SOAP-ENV:Body>
> <p:PatientDURProfileRequest
> xmlns:p="http://www.cvscaremark.com/esl/isp/messages/1_0">
>   <esl:AppMsgID>******</esl:AppMsgID>
>   <esl:Version>1.0</esl:Version>
>   <esl:MsgDateTimestamp>*******</esl:MsgDateTimestamp>
>   <p:sourceSystemID>
>     <eldm:sourceSystemName>*******</eldm:sourceSystemName>
>     <eldm:sourceSystemKey KeyName="PatientIdentifier">
>       <eldm:KeyValue>*******</eldm:KeyValue>
>     </eldm:sourceSystemKey>
>     <eldm:effectiveDate>*******</eldm:effectiveDate>
>     <eldm:termDate>*******</eldm:termDate>
>   </p:sourceSystemID>
>   <p:startDate>*******</p:startDate>
>   <p:endDate>*******</p:endDate>
>   <p:lineOfBusinessCode>*******</p:lineOfBusinessCode>
> </p:PatientDURProfileRequest>
> </SOAP-ENV:Body>
> </SOAP-ENV:Envelope>
> 
> 
> 
> *Actual Result:*
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:ns3="http://www.cvscaremark.com/esl/entities/1_0"
>  xmlns:ns2="http://www.cvscaremark.com/esl/isp/messages/1_0">
> <soap:Body>
>    <PatientDURProfileRequest
> xmlns="http://www.cvscaremark.com/esl/isp/messages/1_0">
>    <AppMsgID
> xmlns="http://www.cvscaremark.com/esl/entities/1_0">*****</AppMsgID
> >
>     <MsgDateTimestamp
> xmlns="http://www.cvscaremark.com/esl/entities/1_0">*****</MsgDateT
> imestamp><sourceSystemID>
> 	<sourceSystemName
> xmlns="http://www.cvscaremark.com/esl/eldm/entities/1_0">******</so
> urceSystemName>
> <sourceSystemKey
> xmlns="http://www.cvscaremark.com/esl/eldm/entities/1_0"
> PatientIdentifier">
> 	<KeyValue>******</KeyValue>
> 	            </sourceSystemKey>
>                  </sourceSystemID>
>               </PatientDURProfileRequest>
>             </soap:Body>
> </soap:Envelope>
> 
> 
> 
> I have tried following options to resolve the same but no success has been
> acheived:
> 1. XMLOptions - not working
> 2. Adding namespace in "soap.env.ns.map" using cxf.xml and also using
> interceptor
> 
> Please provide the solution, if anyone has faced the sae issue
> 
> 
> 
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Issue-in-
> Prefix-management-of-namespace-in-cxf-2-5-10-tp5733766.html
> Sent from the cxf-user mailing list archive at Nabble.com.