Thanks, Vinh - I will do that. In the meantime, createElement(QName, Object) always strips the root element when the Object is a DOM Element (check the JavaDoc). If you want to just append the root element under the newly-created Element, check out the JavaDoc for createElement(Document, QName, Node, boolean), which allows you to specify this choice.
Thanks, Dan "Vinh Nguyen \(vinguye2\)" <[EMAIL PROTECTED]> wrote on 11/09/2006 03:45:48 AM: > Dan, > I will post an issue to the XmlBeans group about #1 below. If you can, > please look into #2 and let me know if it's actually a bug. You can > update the JIRA issue I opened earlier today, since it relates to this > problem. Thanks for your help! > -Vinh > > -----Original Message----- > From: Vinh Nguyen (vinguye2) > Sent: Thursday, November 09, 2006 12:40 AM > To: [email protected] > Subject: RE: xmlbeans and muse > > Ok, I figured out the problem. Actually, it's two problems. The > following code now works, and I can send a complex type notification. I > can also successfully deserialize it on the consumer end and rebuild my > javabean from the xml. The fix was a slight modification to my original > producer code. > > BoxDocument doc = BoxDocument.Factory.newInstance(); > BoxType type = doc.addNewBox(); > type.setWidth(BigInteger.valueOf(123)); > type.setHeight(BigInteger.valueOf(123)); > Element payload = XmlUtils.getFirstElement(doc.newDomNode()); > // fix is in this line > > NotificationProducer wsn = ... > wsn.publish(TOPIC_NAME, payload); > > The two problems (or bugs?): > > 1) XmlBeans - the XmlObject base class for all the javabeans seems to > have a bug with doc.getDomNode(). This method fails to preserve the > namespace prefix. Calling doc.newDomeNode() seems to solve the problem, > and all xml artifacts seem to be preserved ok. > > 2) NotificationProducer (Muse) - fails to properly handle message > Elements that do NOT have namespace prefixes. The result is that the > notification does not get sent out, and no errors seem to be thrown at > all. I confirmed this when using the Element from doc.getDomNode(), > which returns a node WITHOUT any namespace prefixes. > NotificationProducer will fail with this Element. But, the Element from > doc.newDomNode() does have the prefixes, and NotificationProducer will > then send the message element successfully. > > Here's the successful test output trace: > > [CLIENT TRACE] SOAP envelope contents (outgoing): > > <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"> > <soap:Header> > <wsa:To > xmlns:wsa="http://www.w3.org/2005/08/addressing">http://10.21.155.92:808 > 0/MuseBox/services/SimpleWsnConsumer</wsa:To> > <wsa:Action > xmlns:wsa="http://www.w3.org/2005/08/addressing">http://docs.oasis-open. > org/wsn/bw-2/NotificationConsumer/NotifyRequest</wsa:Action> > <wsa:MessageID > xmlns:wsa="http://www.w3.org/2005/08/addressing">uuid:8e95e926-9af1-bf71 > -eb38-dba159b59146</wsa:MessageID> > <wsa:From xmlns:wsa="http://www.w3.org/2005/08/addressing"> > <wsa:ReferenceParameters > xmlns:wsa="http://www.w3.org/2005/08/addressing"/> > > <wsa:Address>http://10.21.155.92:8080/MuseBox/services/SimpleWsnProducer > </wsa:Address> > </wsa:From> > </soap:Header> > <soap:Body> > <wsnt:Notify xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2"> > <wsnt:NotificationMessage > xmlns:box="http://cisco.com/musebox/schemas/box" > xmlns:muse-wsa="http://ws.apache.org/muse/addressing" > 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://10.21.155.92:808 > 0/MuseBox/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:wsnp="http://cisco.com/musebox/wsnp">wsnp:MyTopic2</wsnt:Topic> > <wsnt:ProducerReference> > <wsa:ReferenceParameters > xmlns:wsa="http://www.w3.org/2005/08/addressing"/> > <wsa:Address > xmlns:wsa="http://www.w3.org/2005/08/addressing">http://10.21.155.92:808 > 0/MuseBox/services/SimpleWsnProducer</wsa:Address> > </wsnt:ProducerReference> > <wsnt:Message> > <box:Box > xmlns:box="http://cisco.com/musebox/schemas/box"> > <box:width>123</box:width> > <box:height>123</box:height> > </box:Box> > </wsnt:Message> > </wsnt:NotificationMessage> > </wsnt:Notify> > </soap:Body> > </soap:Envelope> > > > > -----Original Message----- > From: Vinh Nguyen (vinguye2) > Sent: Wednesday, November 08, 2006 3:00 PM > To: [email protected] > Subject: RE: xmlbeans and muse > > Actually, here is the XML from doc.xmlText(): > > <box:Box > xmlns:box="http://cisco.com/musebox/schemas/box"><box:width>123</box:wid > th><box:height>123</box:height></box:Box> > > So it looks like XmlBeans does keep the prefixes. But when outputting > from Muse's XmlUtils.toString(), the prefixes are lost. I'm wondering > if the problem is with XmlUtils, because it always seems to strip the > top node "Box". Even with XmlUtils.createElement(QName,Element), it > seems to strip the existing element's top node when creating the new > one. > > > -----Original Message----- > From: Daniel Jemiolo [mailto:[EMAIL PROTECTED] > Sent: Wednesday, November 08, 2006 2:04 PM > To: [email protected] > Subject: RE: xmlbeans and muse > > How are you setting up the subscription? I'm guessing that the message > is not being sent out because it doesn't match a subscription filter OR > it the subscription is failing. Let me know what test code you're using > (if it's WsnTestClient or a modified version) and the client-side trace. > > Also - I notice the XmlBeans XML doesn't have prefixes in the elements. > In our experience, the SAAJ implementations of Axis 1.x and Axis2 do not > handle default namespaces and empty prefixes well, leading us to hack > around the issue (basically, always use prefixes). The XmlBeans XML is > valid, I'm just reporting troubles we've had with Axis. I want to test > to see if the SOAP engine is failing with a runtime exception in the > SOAP processor, which you don't see w/o a SOAP monitor. > > Can you open a JIRA item for this and attach your WAR files (producer > and consumer)? That way I can debug myself and determine if it's a > producer, consumer, or Axis problem. Don't send it to muse-* because the > Apache spam filter traps any message with large attachments. I'll reply > to the list with any findings. > > Dan > > > "Vinh Nguyen \(vinguye2\)" <[EMAIL PROTECTED]> wrote on 11/08/2006 > 04:34:45 PM: > > > Dan, > > As a note, if I use the Element object created in the code below and > > pass it to the NotificationProducer, the message doesn't get sent out > at > > all. No errors are being thrown either, so it's difficult to figure > out > > the problem. > > -Vinh > > > > > > -----Original Message----- > > From: Vinh Nguyen (vinguye2) > > Sent: Wednesday, November 08, 2006 1:13 PM > > To: [email protected] > > Subject: RE: xmlbeans and muse > > > > Thanks Dan, > > Here's the test output. > > > > > > Here is the XML from XmlBeans: > > > > <?xml version="1.0" encoding="UTF-8"?> <Box > > xmlns="http://cisco.com/musebox/schemas/box"> > > <width>123</width> > > <height>123</height> > > </Box> > > > > Here is the message payload: > > > > <?xml version="1.0" encoding="UTF-8"?> <wsnp:MyMessage > > xmlns:wsnp="http://cisco.com/musebox/wsnp"> > > <width xmlns="http://cisco.com/musebox/schemas/box">123</width> > > <height xmlns="http://cisco.com/musebox/schemas/box">123</height> > > </wsnp:MyMessage> > > > > Here is another way of doing the same thing: > > > > <?xml version="1.0" encoding="UTF-8"?> <wsnp:MyMessage > > xmlns:wsnp="http://cisco.com/musebox/wsnp"> > > <width xmlns="http://cisco.com/musebox/schemas/box">123</width> > > <height xmlns="http://cisco.com/musebox/schemas/box">123</height> > > </wsnp:MyMessage> > > > > > > > > -----Original Message----- > > From: Daniel Jemiolo [mailto:[EMAIL PROTECTED] > > Sent: Wednesday, November 08, 2006 10:14 AM > > To: [email protected] > > Subject: RE: xmlbeans and muse > > > > I'm guessing it's just a matter of DOM API usage, but for sanity > > checks, try running the following code and let me know what the output > > is: > > > > > > BoxDocument doc = BoxDocument.Factory.newInstance(); > > BoxType type = doc.addNewBoxType(); > > type.setWidth(100); > > type.setHeight(100); > > > > Document dom = (Document)doc.getDomNode(); Element boxElement = > > XmlUtils.getFirstElement(dom); > > > > System.out.println("Here is the XML from XmlBeans:\n"); > > System.out.println(XmlUtils.toString(boxElement)); > > > > QName name = new QName(NAMESPACE_URI, "MyMessage", PREFIX); Element > > payload = XmlUtils.createElement(name, boxElement); > > > > System.out.println("Here is the message payload:\n"); > > System.out.println(XmlUtils.toString(payload)); > > > > Element anotherTest = XmlUtils.createElement(name); > > XmlUtils.moveSubTree(boxElement, anotherTest); > > > > System.out.println("Here is another way of doing the same thing:\n"); > > System.out.println(XmlUtils.toString(anotherTest)); > > > > > > > > > > "Vinh Nguyen \(vinguye2\)" <[EMAIL PROTECTED]> wrote on 11/08/2006 > > 04:59:53 AM: > > > > > I should also ask what type of objects are allowed to be passed in > > > notification messages? Just strings, or any Element object? I > tried > > > the following code to translate my bean to an Element, but the > > > notification doesn't get sent out at all when creating the Element > > this > > > way. No errors are thrown either, so I can't figure out what is > wrong > > > > > with the Element I'm using. This is even when I peek into the > Element > > > > > by printing out it's namespaceURI, node name, etc., and it looks > fine > > to > > > me. > > > > > > QName name = new QName(NAMESPACE_URI, "MyMessage", PREFIX); Element > > > payload = XmlUtils.createElement(name, > > > ((Document)doc.getDomNode()).getDocumentElement()); > > > > > > > > > > > > -----Original Message----- > > > From: Vinh Nguyen (vinguye2) > > > Sent: Wednesday, November 08, 2006 1:06 AM > > > To: [email protected] > > > Subject: xmlbeans and muse > > > > > > Hi all, > > > I'm using XmlBeans with Muse for working with custom object types. > > Can > > > anyone help with the following code? Basically, I'm trying to > convert > > a > > > bean object to an xml Element object, which I can then pass to the > > > NotificationsProducer to send out notifications containing a custom > > > object. Then, later on the consumer side, I want to translate the > xml > > > > > back to the bean. The problem is how to do the conversion to an > > > Element. I've tried several ways without success, or perhaps it's > > > because after seeing various xml output forms, I'm getting confused > > with > > > what the xml should look like in the console trace. Any help is > > > appreciated. Thanks! > > > -Vinh > > > > > > BoxDocument doc = BoxDocument.Factory.newInstance(); > > > BoxType type = doc.addNewBoxType(); > > > type.setWidth(100); > > > type.setHeight(100); > > > > > > Element payload = ... ? > > > > > > QName name = ... > > > NotificationProducer np = ... > > > np.publish(name, payload); > > > > > > > > > > --------------------------------------------------------------------- > > > 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] > > > > --------------------------------------------------------------------- > > 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] > > > > > --------------------------------------------------------------------- > 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] > > --------------------------------------------------------------------- > 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] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
