Hello,

I have created a simple NotificationProducer service that displays the
content of any Subscribe message which is received. Especially, it
prints the content of otherAttributes map inside the
topicExpressionType object associated to the subscribe message.
Hereafter, a small piece of code to understand which data structure I
am considering:

> ((JAXBElement<TopicExpressionType>) 
> subscribeMessage.getFilter().getAny().get(0)).getValue().getOtherAttributes()

Then, I create a simple Subscribe payload that is sent to the
NotificationProducer service thanks to soapui:

> <Subscribe xmlns="http://docs.oasis-open.org/wsn/b-2";
>       xmlns:ns2="http://docs.oasis-open.org/wsrf/bf-2"; 
> xmlns:ns4="http://docs.oasis-open.org/wsn/t-1";
>       xmlns:ns3="http://www.w3.org/2005/08/addressing"; 
> xmlns:ns5="http://com.petalslink.esstar/admin/model/datatype/1.0";
>       xmlns:ns6="http://docs.oasis-open.org/wsrf/rp-2";>
>       <ConsumerReference>
>               <ns3:Address>http://192.168.2.1:8792/subscriber2</ns3:Address>
>               <ns3:ReferenceParameters />
>       </ConsumerReference>
>       <Filter>
>               <TopicExpression 
> Dialect="http://www.w3.org/TR/1999/REC-xpath-19991116";
>                       
> xmlns:test3="http://example.org/namespace/3/";>test3:TestUc3</TopicExpression>
>       </Filter>
> </Subscribe>

On the service side, the otherAttributes is empty whereas I expect to
have an entry for *xmlns:test3="http://example.org/namespace/3/"*.
However, if I replace :

> xmlns:test3="http://example.org/namespace/3/";

by:

> xmlns:test="http://example/testns"; 
> test:test3="http://example.org/namespace/3/";

the otherAttributes map contains an entry for
*test:test3="http://example.org/namespace/3/"* but still the attribute
*xmlns:test* is missing. It seems that attributes with xmlns namespace
are not put inside the otherAttributes map when the subscribe message
is reconstructed. Is it a correct behavior? Is there a way to retrieve
these xmlns declarations for the topic expression element from the
Subscribe object?

Also, I have tried to build a Subscribe object programmatically in
order to invoke the Notify method with a CXF client and I noticed that
when I put a QName inside the otherAttributes map:

> topicExpressionType.getOtherAttributes().put(
>                new QName(...), topicNamespace);

It is not possible to specify a QName value that uses the xmlns prefix
and namespace:

> new QName(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, topicNsPrefix, 
> XMLConstants.XMLNS_ATTRIBUTE)

otherwise, when the subscribe request is unserialized, I get:

> Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: 
> Unmarshalling Error: Trying to declare prefix 'xmlns' (illegal as per NS 1.1 
> #4)

Why it is forbidden? This is certainly a trivial question, but I would
like to understand.

Kind Regards,

Laurent Pellegrino

Reply via email to