You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Parin <pk...@yahoo-inc.com> on 2009/07/22 22:48:46 UTC
how to control namespace prefix on child elements during Aegis
serialization
Hi,
I am using CXF 2.1.3 with Aegis data binding. I am getting the following
SOAP response right now with namespace prefix on every child element inside
the greetResponse element.
CURRENT OUTPUT
-----------------
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
</soap:Header>
<soap:Body>
<ns1:greetResponse xmlns:ns1="http://myexample.com">
<ns1:out>name</ns1:out>
</ns1:greetResponse>
</soap:Body>
</soap:Envelope>
I would like greetResponse element to have a default namepsace and no
prefixes on the child element. Can someone please tell me how to achieve the
following?
EXPECTED OUTPUT
------------------
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
</soap:Header>
<soap:Body>
<greetResponse xmlns="http://myexample.com">
<out>name</out>
</greetResponse>
</soap:Body>
</soap:Envelope>
My service endpoint:
====================
package com.myexample;
@WebService(name = "SampleGreetingService", "http://myexample.com")
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use =
SOAPBinding.Use.LITERAL, parameterStyle =
SOAPBinding.ParameterStyle.WRAPPED)
public interface SampleGreetingService {
@WebResult(name="out")
public String greet(@WebParam(name="greetInput")SampleGreetInput
greetInput );
}
Data object
=======
package com.myexample;
import org.apache.cxf.aegis.type.java5.XmlType;
@XmlType(namespace = "http://myexample.com")
public class SampleGreetInput {
String name;
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
}
Thanks in advance,
- parin
--
View this message in context: http://www.nabble.com/how-to-control-namespace-prefix-on-child-elements-during-Aegis-serialization-tp24614281p24614281.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: how to control namespace prefix on child elements during Aegis serialization
Posted by Daniel Kulp <dk...@apache.org>.
On Mon July 27 2009 6:04:18 pm Parin wrote:
> Hi Dan,
>
> I tried CXF 2.1.5 but when I looked at the CXF code, I don't think
> NamespaceMap will help as there is a non-configurable logic in
> WrappedOutInterceptor.java that sets ns+x (x is a integer > 0) as the
> prefix on the xxxResponse object that wraps the actual output.
Ah. Right. JAXB doesn't end up using the WrappedOutInterceptor in most
cases.
I've updated the WrappedOutInterceptor to use the databindings namespace map
for defining the namespace on the wrapper element. Hopefully that will help.
Any chance you could test that out at all?
Dan
> for e.g. <ns1:greetResponse xmlns:ns1="http://myexample.com"> in my
> example.
>
> The only way I found to overcome it was to replace the
> WrappedOutInterceptor by my own MyWrappedOutInterceptor that does not add
> the ns+x prefix. SOAPBindingFactory had to be replaced in spring config
> with my own SOAPBindingFactory so that it replaces MyWrappedOutInterceptor
> instead of WrappedOutInterceptor in the list of interceptors.
>
> Please let me know if there is any easier way to override
> WrappedOutInterceptor
>
> Thanks,
> parin
>
> dkulp wrote:
> > The AegisDataBinding object has a NamespaceMap property which is a map of
> > namespace -> prefix to use.
> >
> > That said, that may have been added in 2.1.4. Not sure if that was there
> > in
> > 2.1.3.
> >
> > Dan
> >
> > On Wed July 22 2009 4:48:46 pm Parin wrote:
> >> Hi,
> >>
> >> I am using CXF 2.1.3 with Aegis data binding. I am getting the following
> >> SOAP response right now with namespace prefix on every child element
> >> inside
> >> the greetResponse element.
> >>
> >> CURRENT OUTPUT
> >> -----------------
> >> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
> >> <soap:Header>
> >> </soap:Header>
> >> <soap:Body>
> >> <ns1:greetResponse xmlns:ns1="http://myexample.com">
> >> <ns1:out>name</ns1:out>
> >> </ns1:greetResponse>
> >> </soap:Body>
> >> </soap:Envelope>
> >>
> >> I would like greetResponse element to have a default namepsace and no
> >> prefixes on the child element. Can someone please tell me how to achieve
> >> the following?
> >>
> >> EXPECTED OUTPUT
> >> ------------------
> >> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
> >> <soap:Header>
> >> </soap:Header>
> >> <soap:Body>
> >> <greetResponse xmlns="http://myexample.com">
> >> <out>name</out>
> >> </greetResponse>
> >> </soap:Body>
> >> </soap:Envelope>
> >>
> >>
> >> My service endpoint:
> >> ====================
> >> package com.myexample;
> >>
> >> @WebService(name = "SampleGreetingService", "http://myexample.com")
> >> @SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use =
> >> SOAPBinding.Use.LITERAL, parameterStyle =
> >> SOAPBinding.ParameterStyle.WRAPPED)
> >>
> >> public interface SampleGreetingService {
> >>
> >> @WebResult(name="out")
> >> public String greet(@WebParam(name="greetInput")SampleGreetInput
> >> greetInput );
> >> }
> >>
> >> Data object
> >> =======
> >>
> >> package com.myexample;
> >>
> >> import org.apache.cxf.aegis.type.java5.XmlType;
> >>
> >> @XmlType(namespace = "http://myexample.com")
> >> public class SampleGreetInput {
> >> String name;
> >> public String getName() {
> >> return name;
> >> }
> >> /**
> >> * @param name the name to set
> >> */
> >> public void setName(String name) {
> >> this.name = name;
> >> }
> >> }
> >>
> >> Thanks in advance,
> >> - parin
> >
> > --
> > Daniel Kulp
> > dkulp@apache.org
> > http://www.dankulp.com/blog
--
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog
Re: how to control namespace prefix on child elements during Aegis
serialization
Posted by Parin <pk...@yahoo-inc.com>.
Hi Dan,
I tried CXF 2.1.5 but when I looked at the CXF code, I don't think
NamespaceMap will help as there is a non-configurable logic in
WrappedOutInterceptor.java that sets ns+x (x is a integer > 0) as the
prefix on the xxxResponse object that wraps the actual output.
for e.g. <ns1:greetResponse xmlns:ns1="http://myexample.com"> in my
example.
The only way I found to overcome it was to replace the WrappedOutInterceptor
by my own MyWrappedOutInterceptor that does not add the ns+x prefix.
SOAPBindingFactory had to be replaced in spring config with my own
SOAPBindingFactory so that it replaces MyWrappedOutInterceptor instead of
WrappedOutInterceptor in the list of interceptors.
Please let me know if there is any easier way to override
WrappedOutInterceptor
Thanks,
parin
dkulp wrote:
>
>
> The AegisDataBinding object has a NamespaceMap property which is a map of
> namespace -> prefix to use.
>
> That said, that may have been added in 2.1.4. Not sure if that was there
> in
> 2.1.3.
>
> Dan
>
>
> On Wed July 22 2009 4:48:46 pm Parin wrote:
>> Hi,
>>
>> I am using CXF 2.1.3 with Aegis data binding. I am getting the following
>> SOAP response right now with namespace prefix on every child element
>> inside
>> the greetResponse element.
>>
>> CURRENT OUTPUT
>> -----------------
>> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
>> <soap:Header>
>> </soap:Header>
>> <soap:Body>
>> <ns1:greetResponse xmlns:ns1="http://myexample.com">
>> <ns1:out>name</ns1:out>
>> </ns1:greetResponse>
>> </soap:Body>
>> </soap:Envelope>
>>
>> I would like greetResponse element to have a default namepsace and no
>> prefixes on the child element. Can someone please tell me how to achieve
>> the following?
>>
>> EXPECTED OUTPUT
>> ------------------
>> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
>> <soap:Header>
>> </soap:Header>
>> <soap:Body>
>> <greetResponse xmlns="http://myexample.com">
>> <out>name</out>
>> </greetResponse>
>> </soap:Body>
>> </soap:Envelope>
>>
>>
>> My service endpoint:
>> ====================
>> package com.myexample;
>>
>> @WebService(name = "SampleGreetingService", "http://myexample.com")
>> @SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use =
>> SOAPBinding.Use.LITERAL, parameterStyle =
>> SOAPBinding.ParameterStyle.WRAPPED)
>>
>> public interface SampleGreetingService {
>>
>> @WebResult(name="out")
>> public String greet(@WebParam(name="greetInput")SampleGreetInput
>> greetInput );
>> }
>>
>> Data object
>> =======
>>
>> package com.myexample;
>>
>> import org.apache.cxf.aegis.type.java5.XmlType;
>>
>> @XmlType(namespace = "http://myexample.com")
>> public class SampleGreetInput {
>> String name;
>> public String getName() {
>> return name;
>> }
>> /**
>> * @param name the name to set
>> */
>> public void setName(String name) {
>> this.name = name;
>> }
>> }
>>
>> Thanks in advance,
>> - parin
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
>
>
--
View this message in context: http://www.nabble.com/how-to-control-namespace-prefix-on-child-elements-during-Aegis-serialization-tp24614281p24689102.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: how to control namespace prefix on child elements during Aegis serialization
Posted by Daniel Kulp <dk...@apache.org>.
The AegisDataBinding object has a NamespaceMap property which is a map of
namespace -> prefix to use.
That said, that may have been added in 2.1.4. Not sure if that was there in
2.1.3.
Dan
On Wed July 22 2009 4:48:46 pm Parin wrote:
> Hi,
>
> I am using CXF 2.1.3 with Aegis data binding. I am getting the following
> SOAP response right now with namespace prefix on every child element inside
> the greetResponse element.
>
> CURRENT OUTPUT
> -----------------
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
> <soap:Header>
> </soap:Header>
> <soap:Body>
> <ns1:greetResponse xmlns:ns1="http://myexample.com">
> <ns1:out>name</ns1:out>
> </ns1:greetResponse>
> </soap:Body>
> </soap:Envelope>
>
> I would like greetResponse element to have a default namepsace and no
> prefixes on the child element. Can someone please tell me how to achieve
> the following?
>
> EXPECTED OUTPUT
> ------------------
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
> <soap:Header>
> </soap:Header>
> <soap:Body>
> <greetResponse xmlns="http://myexample.com">
> <out>name</out>
> </greetResponse>
> </soap:Body>
> </soap:Envelope>
>
>
> My service endpoint:
> ====================
> package com.myexample;
>
> @WebService(name = "SampleGreetingService", "http://myexample.com")
> @SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use =
> SOAPBinding.Use.LITERAL, parameterStyle =
> SOAPBinding.ParameterStyle.WRAPPED)
>
> public interface SampleGreetingService {
>
> @WebResult(name="out")
> public String greet(@WebParam(name="greetInput")SampleGreetInput
> greetInput );
> }
>
> Data object
> =======
>
> package com.myexample;
>
> import org.apache.cxf.aegis.type.java5.XmlType;
>
> @XmlType(namespace = "http://myexample.com")
> public class SampleGreetInput {
> String name;
> public String getName() {
> return name;
> }
> /**
> * @param name the name to set
> */
> public void setName(String name) {
> this.name = name;
> }
> }
>
> Thanks in advance,
> - parin
--
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog