For future reference I got this working by creating the WS-Notification
client using spring jaxws:client configuration to add extra JAXB classes.
<jaxws:client id="notificationBrokerClient"
serviceClass="org.oasis_open.docs.wsn.brw_2.NotificationBroker"
address="http://localhost:8080/ws/notificationBroker">
<jaxws:dataBinding>
<bean class="org.apache.cxf.jaxb.JAXBDataBinding">
<property name="extraClass">
<list>
<value>package.WSEvent</value>
</list>
</property>
</bean>
</jaxws:dataBinding>
</jaxws:client>
On 24 February 2012 15:59, Mark Anderson <[email protected]> wrote:
> I want to use org.apache.cxf.wsn.client.NotificationBroker to do the
> following:
>
> notificationBroker.notify("events", new WSEvent(1, "message"));
>
> Where WSEvent is defined as follows:
>
> @XmlRootElement(name="event")
> public class WSEvent
> {
> private int classification;
> private String message;
>
> public WSEvent(int classification, String message)
> {
> this.classification = classification;
> this.message = message;
> }
> }
>
> However, when I run this code I get the following exception message:
>
> Marshalling Error: WSEvent is not known to this context
> [java] javax.xml.ws.soap.SOAPFaultException: Marshalling Error:
> WSEvent is not known to this context
> [java] at
> org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:156)
> [java] at $Proxy87.notify(Unknown Source)
> [java] at
> org.apache.cxf.wsn.client.NotificationBroker.notify(NotificationBroker.java:105)
> [java] at
> org.apache.cxf.wsn.client.NotificationBroker.notify(NotificationBroker.java:88)
> [java] at <snip>
> [java] Caused by: javax.xml.bind.MarshalException
> [java] - with linked exception:
> [java] [com.sun.istack.internal.SAXException2: WSEvent is not known
> to this context
> [java] javax.xml.bind.JAXBException: WSEvent is not known to this
> context]
> [java] at
> com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:311)
> [java] at
> com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:236)
> [java] at
> javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:95)
> [java] at
> org.apache.cxf.jaxb.JAXBEncoderDecoder.writeObject(JAXBEncoderDecoder.java:552)
> [java] at
> org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:236)
> [java] at
> org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java:169)
> [java] at
> org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:110)
> [java] at
> org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutInterceptor.java:68)
>
> This is my first time using JAXB but from searching the web I think that
> the JAXBContext used in JaxWSClientProxy is not aware of the WSEvent class
> so cannot handle it?
>
> Is there any way to make this work? Am I even on the right track with what
> I am trying to do?
>
> Thanks,
> Mark
>
>