Doing 

Element[] elem = new Element[data.size()];
for (int i=0;i<elem.length;i++)
        elem[i] = data.get(i).toXML();
wsn.publish(messageName, elem);

makes no difference. I still get in the notifications only the last element
that was in the array at serialization time.


Vinh Nguyen (vinguye2) wrote:
> 
> Try explicitly converting your XmlSerializable[] to an Element[], and
> then call producer.publish(QName,Element[]).  See if that makes a
> difference?
> 
> 
> -----Original Message-----
> From: Bogdan Solomon [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, August 16, 2007 7:23 AM
> To: [email protected]
> Subject: Array serialization problem in notifications
> 
> 
> I think the problem is in my serialization code but I just can't figured
> out what it is. 
> 
> I am trying to send via notifications an array of custom objects which
> implement XmlSerializable. I logged some messages and I see that all the
> objects in the array get serialized (the toXml() method is called for
> each of them), but the final notification only contains the last element
> in the array.
> 
> Here is the notification code (the data structure is an ArrayList):
> 
> QName messageName = new
> QName("http://autonomic.ibm.com/muse/sensor/execution/Topics";,
> "MeasuredDataTopic", "topics1");
> wsn.publish(messageName, data.toArray(new DataInterface[0]));
> 
> and here is the serialization code:
> 
> public Element toXML() {
>               System.out.println("Serializing:"+name);
>               
>               Element root =
> XmlUtils.createElement(XmlUtils.EMPTY_DOC,rootQName);
>               
>               //Element root = XmlUtils.createElement(rootQName);
>               
>               Element name = XmlUtils.createElement(nameQName,
> getName());
>               
>               Element dataValue =
> XmlUtils.createElement(dataValueQName,getDataValue());
>               
>               Element desc =
> XmlUtils.createElement(descQName,getDescription());
>               
>               Element valueType =
> XmlUtils.createElement(valueTypeQName,getDataType());
>               
>               root.appendChild(name);
>               root.appendChild(dataValue);
>               root.appendChild(desc);
>               root.appendChild(valueType);
>               
>               return root;
>       }
> 
> The resulting Notification looks as follows:
> 
> <soap:Body>
>         <wsnt:Notify xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2";>
>             <wsnt:NotificationMessage
>                 xmlns:muse-wsa="http://ws.apache.org/muse/addressing";
>                
> xmlns:sensor="http://autonomic.ibm.com/muse/filter/execution";
>                 xmlns:wsa="http://www.w3.org/2005/08/addressing";
> xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2";>
>                 <wsnt:SubscriptionReference>
>                     <wsa:Address
> xmlns:wsa="http://www.w3.org/2005/08/addressing";>http://192.168.32.23:90
> 81/AutonomicSensor/services/SubscriptionManager</wsa:Address>
>                     <wsa:ReferenceParameters
> xmlns:wsa="http://www.w3.org/2005/08/addressing";>
>                         <muse-wsa:ResourceId
> xmlns:muse-wsa="http://ws.apache.org/muse/addressing";>MuseResource-1</mu
> se-wsa:ResourceId>
>                     </wsa:ReferenceParameters>
>                 </wsnt:SubscriptionReference>
>                 <wsnt:Topic
>                    
> Dialect="http://docs.oasis-open.org/wsn/t-1/TopicExpression/Concrete";
> xmlns:topics1="http://autonomic.ibm.com/muse/sensor/execution/Topics";>to
> pics1:MeasuredDataTopic</wsnt:Topic>
>                 <wsnt:ProducerReference>
>                     <wsa:Address
> xmlns:wsa="http://www.w3.org/2005/08/addressing";>http://192.168.32.23:90
> 81/AutonomicSensor/services/sensor</wsa:Address>
>                     <wsa:ReferenceParameters
> xmlns:wsa="http://www.w3.org/2005/08/addressing";>
>                         <muse-wsa:ResourceId
> xmlns:muse-wsa="http://ws.apache.org/muse/addressing";>MuseResource-13</m
> use-wsa:ResourceId>
>                     </wsa:ReferenceParameters>
>                 </wsnt:ProducerReference>
>                 <wsnt:Message>
>                     <sensor:FilteredData
> xmlns:sensor="http://autonomic.ibm.com/muse/filter/execution";>
>                        
> <sensor:name>TradeScenarioServlet-ServiceTime-TotalTime</sensor:name>
>                         <sensor:dataValue>0</sensor:dataValue>
>                         <sensor:description/>
>                         <sensor:valueType>Long</sensor:valueType>
>                     </sensor:FilteredData>
>                 </wsnt:Message>
>             </wsnt:NotificationMessage>
>         </wsnt:Notify>
>     </soap:Body> 
> 
> But my message should contain 7 FilteredData structures as I have 7
> DataInterface objects.
> --
> View this message in context:
> http://www.nabble.com/Array-serialization-problem-in-notifications-tf427
> 9966.html#a12182356
> Sent from the Muse User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Array-serialization-problem-in-notifications-tf4279966.html#a12186450
Sent from the Muse User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to