You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by pazzodalegare <pa...@gmail.com> on 2012/06/18 14:40:02 UTC
ws-notification (cxf v. 2.6.1): how to notify custom message
Dear All,
I'm trying to modify ws-notification example to send my custom payload.
So I instruct the NotificationBroker about new classes:
notificationBroker.setExtraClasses(org.apache.cxf.bindings.my.package.ObjectFactory.class);
and marhall operation are going well.
On Consumer side I receive my notifications but they are instance of
com.sun.org.apache.xerces.internal.dom.ElementNSImpl
I would like to have it unmarshalled to use my object. How I can do that?
mp
--
View this message in context: http://cxf.547215.n5.nabble.com/ws-notification-cxf-v-2-6-1-how-to-notify-custom-message-tp5709934.html
Sent from the cxf-dev mailing list archive at Nabble.com.
Re: ws-notification (cxf v. 2.6.1): how to notify custom message
Posted by Daniel Kulp <dk...@apache.org>.
On Monday, June 18, 2012 05:40:02 AM pazzodalegare wrote:
> Dear All,
>
> I'm trying to modify ws-notification example to send my custom payload.
>
> So I instruct the NotificationBroker about new classes:
>
> notificationBroker.setExtraClasses(org.apache.cxf.bindings.my.package.Obje
> ctFactory.class);
>
> and marhall operation are going well.
>
> On Consumer side I receive my notifications but they are instance of
> com.sun.org.apache.xerces.internal.dom.ElementNSImpl
> I would like to have it unmarshalled to use my object. How I can do that?
The constructor of the Consumer looks like:
public Consumer(Callback callback, String address,
Class<?> ... extraClasses)
You should just be able to add the ObjectFactory there in the extraClasses.
--
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com
Re: ws-notification (cxf v. 2.6.1): how to notify custom message
Posted by pazzodalegare <pa...@gmail.com>.
Finally I found an answer, probably there is a better/cleaner way to do that.
But in any case it's working.
1) I define an unmarshaller for my context
private static Unmarshaller um;
static{
try {
final JAXBContext ctx =
JAXBContext.newInstance(org.apache.cxf.bindings.my.package.ObjectFactory.class.getPackage().getName());
um = ctx.createUnmarshaller();
} catch (final JAXBException e) {
e.printStackTrace();
}
}
2) then I use it to unmarshall "any" part of my custom message:
public void notify(NotificationMessageHolderType message) {
Object unmarshObj=null;
try {
unmarshObj = um.unmarshal( (ElementNSImpl) o);
} catch (JAXBException e) {
e.printStackTrace();
}
....
}
--
View this message in context: http://cxf.547215.n5.nabble.com/ws-notification-cxf-v-2-6-1-how-to-notify-custom-message-tp5709934p5709938.html
Sent from the cxf-dev mailing list archive at Nabble.com.