You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xmlbeans-user@xml.apache.org by Mark Lewis <ma...@mir3.com> on 2004/06/17 19:47:39 UTC

Avoiding unnecessary copying

I have a working program using xmlbeans 1.0.2 to invoke some web
services, but I'm trying to figure out if I can make it more efficient. 
I was hoping someone out there can point me in the right direction.

I'm using SAAJ to invoke web services (document-style), and I need to
pass it a DOM object to send.  I'm currently using
XmlObject.newDomNode() to generate the DOM from my bean, but that makes
a complete copy of my XML as a DOM node prior to sending.

Is anybody familiar with a simple way of invoking a web-service that
doesn't involve this extra copy?

Here's my current code:

            // Convert the XmlBeans object to a DOM-node
            Document document = (Document)xmlData.newDomNode();

            // Create the SOAPMessage and SOAPConnection to send
            SOAPMessage message;
            SOAPConnection connection;
            synchronized(this) {
                message = messageFactory.createMessage();
                connection = connectionFactory.createConnection();
            }

            // Prepare the SOAPMessage
            message.getSOAPHeader().detachNode();
            SOAPBody body = message.getSOAPBody();
            body.addDocument( document );
            message.saveChanges();

            // Send the message
            SOAPMessage response = connection.call(message, endpoint);


Thanks for any pointers,
Mark Lewis


- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/


Re: Avoiding unnecessary copying

Posted by nn <nn...@comcast.net>.
Hi Mark,

I had similar problem to adapt XMLBeans for SAXON.
SAXON depends on specific API, so it was ncessary to create NodeWrapper
class from XmlObject.
This worked, but from performance point of view, this was not satisfactory.
XmlObject(or XMLBeans generated classes) should directly implement these
interfaces.

in the comming new release it will support adding interface for generated
class.
So it may be possible to implement DOM api using this feature.

But DOM API is so standard, it would be useful for XMLBeans to support this
feature directly.(maybe by choosing option for code generation time).

For the DOM API implementation, there are a few issues since XMLBeans does
not follow DOM API structure.
I sent a reply and explained how to implement getChildren etc from
XmlObject.
You can see it.

Another approach is to use AOP approach (e.g, AspectWerkz), then even if
XMLBeans does not have the new feature,  XmlObject(or XMLBean generated
classes) can be mixen and implement given interface magically.

nn


----- Original Message ----- 
From: "Mark Lewis" <ma...@mir3.com>
To: <xm...@xml.apache.org>
Sent: Thursday, June 17, 2004 10:47 AM
Subject: Avoiding unnecessary copying


> I have a working program using xmlbeans 1.0.2 to invoke some web
> services, but I'm trying to figure out if I can make it more efficient.
> I was hoping someone out there can point me in the right direction.
>
> I'm using SAAJ to invoke web services (document-style), and I need to
> pass it a DOM object to send.  I'm currently using
> XmlObject.newDomNode() to generate the DOM from my bean, but that makes
> a complete copy of my XML as a DOM node prior to sending.
>
> Is anybody familiar with a simple way of invoking a web-service that
> doesn't involve this extra copy?
>
> Here's my current code:
>
>             // Convert the XmlBeans object to a DOM-node
>             Document document = (Document)xmlData.newDomNode();
>
>             // Create the SOAPMessage and SOAPConnection to send
>             SOAPMessage message;
>             SOAPConnection connection;
>             synchronized(this) {
>                 message = messageFactory.createMessage();
>                 connection = connectionFactory.createConnection();
>             }
>
>             // Prepare the SOAPMessage
>             message.getSOAPHeader().detachNode();
>             SOAPBody body = message.getSOAPBody();
>             body.addDocument( document );
>             message.saveChanges();
>
>             // Send the message
>             SOAPMessage response = connection.call(message, endpoint);
>
>
> Thanks for any pointers,
> Mark Lewis
>
>
> - ---------------------------------------------------------------------
> To unsubscribe, e-mail:   xmlbeans-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
> Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/
>


- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/


Re: Avoiding unnecessary copying

Posted by nn <nn...@comcast.net>.
Hi Mark,

I had similar problem to adapt XMLBeans for SAXON.
SAXON depends on specific API, so it was ncessary to create NodeWrapper
class from XmlObject.
This worked, but from performance point of view, this was not satisfactory.
XmlObject(or XMLBeans generated classes) should directly implement these
interfaces.

in the comming new release it will support adding interface for generated
class.
So it may be possible to implement DOM api using this feature.

But DOM API is so standard, it would be useful for XMLBeans to support this
feature directly.(maybe by choosing option for code generation time).

For the DOM API implementation, there are a few issues since XMLBeans does
not follow DOM API structure.
I sent a reply and explained how to implement getChildren etc from
XmlObject.
You can see it.

Another approach is to use AOP approach (e.g, AspectWerkz), then even if
XMLBeans does not have the new feature,  XmlObject(or XMLBean generated
classes) can be mixen and implement given interface magically.

nn


----- Original Message ----- 
From: "Mark Lewis" <ma...@mir3.com>
To: <xm...@xml.apache.org>
Sent: Thursday, June 17, 2004 10:47 AM
Subject: Avoiding unnecessary copying


> I have a working program using xmlbeans 1.0.2 to invoke some web
> services, but I'm trying to figure out if I can make it more efficient.
> I was hoping someone out there can point me in the right direction.
>
> I'm using SAAJ to invoke web services (document-style), and I need to
> pass it a DOM object to send.  I'm currently using
> XmlObject.newDomNode() to generate the DOM from my bean, but that makes
> a complete copy of my XML as a DOM node prior to sending.
>
> Is anybody familiar with a simple way of invoking a web-service that
> doesn't involve this extra copy?
>
> Here's my current code:
>
>             // Convert the XmlBeans object to a DOM-node
>             Document document = (Document)xmlData.newDomNode();
>
>             // Create the SOAPMessage and SOAPConnection to send
>             SOAPMessage message;
>             SOAPConnection connection;
>             synchronized(this) {
>                 message = messageFactory.createMessage();
>                 connection = connectionFactory.createConnection();
>             }
>
>             // Prepare the SOAPMessage
>             message.getSOAPHeader().detachNode();
>             SOAPBody body = message.getSOAPBody();
>             body.addDocument( document );
>             message.saveChanges();
>
>             // Send the message
>             SOAPMessage response = connection.call(message, endpoint);
>
>
> Thanks for any pointers,
> Mark Lewis
>
>
> - ---------------------------------------------------------------------
> To unsubscribe, e-mail:   xmlbeans-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
> Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/
>


- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/