You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Pradeep Fernando <pr...@gmail.com> on 2009/03/16 06:19:16 UTC

using Axiom instead of DOM in ServiceClient.

Hi Devs,

Right now Axis2 s' ServiceClient(Dynamic serviceClient) does not
support WSDL2 as it argument. I did few changes to the Code and now it
supports WSDL2 as well. But I would like to draw your attention
regarding few issues.

1. In order to support both WSDL11 & WSDL20 without changing the
method signature of the ServiceClient we need to identify the Given
WSDL using the namespace.

2. In the current code It uses a dom Element to Represent the WSDL.But
in this scenario we need to check the namespace and if it is a WSDL11
Get the javax.wsl.Definition from the reader or else if it is WSDL20,
serialize it and write it to a output stream so we can get it as a
input stream
to build a AxisService out of WSDL20.

3.since the current implementation uses dom element this mechanism
results in a double parsing when its a WSDL20.possible solution is
using
Axiom instead of dom so that when namespace checking it does not parse
the entire WSDL.

4. So i replaced Dom with Axiom and used Doom to create the Dom
element out of Axiom element when need to fed to the readWSDL()
method of the
WSDL reader.

WDYT devs? comments ,suggestions are mostly welcome.
The patch related to this issue can be found in [1]

Thanks in advance,
Pradeep Fernando.

[1] https://issues.apache.org/jira/browse/AXIS2-4253

Re: using Axiom instead of DOM in ServiceClient.

Posted by Sagara Gunathunga <sa...@gmail.com>.
Hi  Pradeep,

in your staring mail

> 3.since the current implementation uses dom element this mechanism
> results in a double parsing when its a WSDL20.possible solution is
> using
> Axiom instead of dom so that when namespace checking it does not parse
> the entire WSDL.

         I agree with this  Axiom based approach to identify the
version of  WSDL document.


>  The way you are suggesting seems to
> be based on Exception handling. So once the Exception is thrown from
> this(if the WSDL is 1.1) then we have to
> parse it again to a *wsdl4j.definition* in order to feed the
> WSDL11ToAxisServiceBuilder. So problem is not addressed.

not exactly , what I'm suggesting is  use your  Axiom based approach
to identify  the the version of WSDL not using
Exception handling . Then if it is a WSDL 1.1 you could parse it with
WSDL4J reader and in the  case of WSDL 2.0 use Woden reader instead of
serialize it to get it as a InputStream.

Because once you provide a InputStream to   WSDL20ToAxisServiceBuilder
it will parse it again to get org.apache.woden.wsdl20.Description my
point is to eliminate this extra serialization step  as follows

1. Identify the version  of the WSDL using your Axiom approach.
2. if it is wsdl1.1 call wsdl4j reader ....and so on
3. if it is a wsdl2.0 call woden reader to get
org.apache.woden.wsdl20.Description and pass this Description to
WSDL20ToAxisServiceBuilder as a constructor argument. ( same way as
WSDL11ToAxisServiceBuilder)


Further you may use Woden's  OMWSDLReader implementation , because
it's also  based on Axiom.

Thanks ,


Sagara Gunathunga

Blog - http://ssagara.blogspot.com
Web - http://sagaras.awardspace.com/

Re: using Axiom instead of DOM in ServiceClient.

Posted by keith chapman <ke...@gmail.com>.
Sounds good to me.

Thanks,
Keith.

On Thu, Mar 19, 2009 at 9:52 AM, Pradeep Fernando <pr...@gmail.com>wrote:

> hi All,
>
> @ Sagara
>
>  yes, possible to use same existing copy, I think this line gives
>> wrong impression .
>>
>>     Description descComp = reader.readWSDL(wsdlLoc);
>
>
> Yes it mislead me. Even the user guide at the woden site gives a wrong
> impression on the above method.
> In that case we can use DOM as the WSDL representation model without a
> problem. So as Sagara proposed
> we can work it out like this.
>
> -read the WSDL and get it as the DOM model.
> -compare namespaces.
> -if WSDL11 read it using reader and get a WSDL4J.Definition, in order to
> feed WSDL11ToAxisServiceBuilder
> -if WSD20 read it using reader(given that it supports DOM), and get a
> WODEN.Description to feed WSDL20ToAxisserviceBuilder.
>
> Thus we have to add a new constructor in the WSDL20ToAxisServiceBuilder
> supporting Woden.Description. This will make
> sure the consistency between WSDL20ToAxisServiceBuilder &
> WSDL11ToAxisserviceBuilder as the latter has a constructor
> supporting WSDL4J.Definiton.
>
> Thanks Andreas,Sagara & Keith for your suggestions,
>
> This seems to be the perfect solution for me. WDYT devs?
>
> cheers,
> Pradeep Fernando.
>
>


-- 
Keith Chapman
Senior Software Engineer
WSO2 Inc.
Oxygenating the Web Service Platform.
http://wso2.org/

blog: http://www.keith-chapman.org

Re: using Axiom instead of DOM in ServiceClient.

Posted by Pradeep Fernando <pr...@gmail.com>.
hi All,

@ Sagara

 yes, possible to use same existing copy, I think this line gives
> wrong impression .
>
>     Description descComp = reader.readWSDL(wsdlLoc);


Yes it mislead me. Even the user guide at the woden site gives a wrong
impression on the above method.
In that case we can use DOM as the WSDL representation model without a
problem. So as Sagara proposed
we can work it out like this.

-read the WSDL and get it as the DOM model.
-compare namespaces.
-if WSDL11 read it using reader and get a WSDL4J.Definition, in order to
feed WSDL11ToAxisServiceBuilder
-if WSD20 read it using reader(given that it supports DOM), and get a
WODEN.Description to feed WSDL20ToAxisserviceBuilder.

Thus we have to add a new constructor in the WSDL20ToAxisServiceBuilder
supporting Woden.Description. This will make
sure the consistency between WSDL20ToAxisServiceBuilder &
WSDL11ToAxisserviceBuilder as the latter has a constructor
supporting WSDL4J.Definiton.

Thanks Andreas,Sagara & Keith for your suggestions,

This seems to be the perfect solution for me. WDYT devs?

cheers,
Pradeep Fernando.

Re: using Axiom instead of DOM in ServiceClient.

Posted by Sagara Gunathunga <sa...@gmail.com>.
Hi Pradeep,

> some latency. So why we cant work using the already acquired copy of the
> WSDL. correct me if i am wrong.

 yes, possible to use same existing copy, I think this line gives
wrong impression .

>>      Description descComp = reader.readWSDL(wsdlLoc);

you have following options

(1) you can use readWSDL(WSDLSource wsdlSource) method for this [1]  ,
because it utilize existing  WSDL document ( as a DOM  Element or
OMElement) without reading  again over the network .
WSDL20ToAxisServiceBuilder already use this approach and WSDLSource
supports to hold DOM Element or OMElement.

 Description descComp = reader.readWSDL(wsdlSource);

there is a one limitation , above method not yet implemented in
OMWSDLReader but hopefully  on next  release . If you plan to follow
Andreas's suggestion you can use above  method with  DOMWSDLReader .

(2) If you still  decide to use use Axiom OMElement to represent WSDL
document  you can use readWSDL(String wsdlURI)  method  on
OMWSDLReader because it doesn't parse whole document until you really
use it so you don't have extra network latency .




[1] -  http://svn.apache.org/repos/asf/webservices/woden/trunk/java/src/org/apache/woden/WSDLReader.java
 (sorry ,  Javadoc link is missing )


Thanks ,

Sagara Gunathunga

Blog - http://ssagara.blogspot.com
Web - http://sagaras.awardspace.com/

Re: using Axiom instead of DOM in ServiceClient.

Posted by Pradeep Fernando <pr...@gmail.com>.
Hi devs,

@ sagara,

try{
>      WSDLFactory factory = WSDLFactory.newInstance();
>      WSDLReader reader = factory.newWSDLReader();
>      reader.setFeature(ReaderFeatures.VALIDATION_FEATURE_ID, true);
>      Description descComp = reader.readWSDL(wsdlLoc);
>     }
>


yes, I got your point. This implementation of course avoid serialization.
but since reader reads the WSDL
from a URL it can be more costly than serialization at times. e.g : getting
a WSDL through network may cause
some latency.So why we cant work using the already acquired copy of the
WSDL. correct me if i am wrong.


@ Andreas,

Both WSDL4J and Woden support DOM, so the obvious solution is to parse
> the WSDL as DOM, check the namespace and then dispatch to WSDL4J or
> Woden. The only problem is that WSDL20ToAxisServiceBuilder only
> supports URLs and input streams, not DOM documents. That could be
> easily changed, so that it is no longer required to parse the WSDL
> twice.


ok , I have misunderstood your suggestion last time. sorry for that.  I too
think that this is the best way to
do this. But not aware of the details regarding wooden.I'll work on this &
modify the Serviceclient and submit the patch.

Thanks for your valuable comments & suggetions,

cheers,
Pradeep Fernando.

Re: using Axiom instead of DOM in ServiceClient.

Posted by Andreas Veithen <an...@gmail.com>.
On Wed, Mar 18, 2009 at 05:57, Pradeep Fernando <pr...@gmail.com> wrote:
> hi devs,
>
> @ Andreas,
>
>> What about improving WSDL20ToAxisServiceBuilder to support DOM and/or
>> Axiom directly (I think Woden supports both)?
>
>
> I don't think that would solve our problem, since in the case of WSDL
> s we parse the whole document
> at some point. So it doesn't matter weather Dom or Axiom used inside
> the builder.correct me if I am wrong.
>

Both WSDL4J and Woden support DOM, so the obvious solution is to parse
the WSDL as DOM, check the namespace and then dispatch to WSDL4J or
Woden. The only problem is that WSDL20ToAxisServiceBuilder only
supports URLs and input streams, not DOM documents. That could be
easily changed, so that it is no longer required to parse the WSDL
twice.

> @ Sagara,
>
>> Instead of  -  if
>> (Constants.NS_URI_WSDL20.
>> equals(documentElementNS.getNamespaceURI()))
>> check try to  use  Woden WSDLReader in the AxisService class.
>>
>>  try{
>>       WSDLFactory factory = WSDLFactory.newInstance();
>>       WSDLReader reader = factory.newWSDLReader();
>>       reader.setFeature(ReaderFeatures.VALIDATION_FEATURE_ID, true);
>>       Description descComp = reader.readWSDL(wsdlLoc);
>>      }
>>
>>  Once you have a org.apache.woden.wsdl20.Description instance you can
>> implement a method something like
>>
>>  createClientSideAxisService(wsdlDescription,
>> wsdlServiceName,portName, options);
>
> Yes , this is possible. In fact this is the exact process currently
> use by the Service Client to build a wsdl4j
> definition & passing it as the argument to WSDL11ToaxisServiceBuilder.
>  The way you are suggesting seems to
> be based on Exception handling. So once the Exception is thrown from
> this(if the WSDL is 1.1) then we have to
> parse it again to a *wsdl4j.definition* in order to feed the
> WSDL11ToAxisServiceBuilder. So problem is not addressed.
>
> Thanks for your valuable suggestions & ideas,
> still feels the mechanism i used to implement this is better, but
> ready to change it if there is a better way.
> waiting for your comments.
>
> Thanks,
> Pradeep Fernando.
>

Re: using Axiom instead of DOM in ServiceClient.

Posted by Pradeep Fernando <pr...@gmail.com>.
hi devs,

@ Andreas,

> What about improving WSDL20ToAxisServiceBuilder to support DOM and/or
> Axiom directly (I think Woden supports both)?


I don't think that would solve our problem, since in the case of WSDL
s we parse the whole document
at some point. So it doesn't matter weather Dom or Axiom used inside
the builder.correct me if I am wrong.

@ Sagara,

> Instead of  -  if
> (Constants.NS_URI_WSDL20.
> equals(documentElementNS.getNamespaceURI()))
> check try to  use  Woden WSDLReader in the AxisService class.
>
>  try{
>       WSDLFactory factory = WSDLFactory.newInstance();
>       WSDLReader reader = factory.newWSDLReader();
>       reader.setFeature(ReaderFeatures.VALIDATION_FEATURE_ID, true);
>       Description descComp = reader.readWSDL(wsdlLoc);
>      }
>
>  Once you have a org.apache.woden.wsdl20.Description instance you can
> implement a method something like
>
>  createClientSideAxisService(wsdlDescription,
> wsdlServiceName,portName, options);

Yes , this is possible. In fact this is the exact process currently
use by the Service Client to build a wsdl4j
definition & passing it as the argument to WSDL11ToaxisServiceBuilder.
 The way you are suggesting seems to
be based on Exception handling. So once the Exception is thrown from
this(if the WSDL is 1.1) then we have to
parse it again to a *wsdl4j.definition* in order to feed the
WSDL11ToAxisServiceBuilder. So problem is not addressed.

Thanks for your valuable suggestions & ideas,
still feels the mechanism i used to implement this is better, but
ready to change it if there is a better way.
waiting for your comments.

Thanks,
Pradeep Fernando.

Re: using Axiom instead of DOM in ServiceClient.

Posted by Sagara Gunathunga <sa...@gmail.com>.
Hi Devs,

> 2. In the current code It uses a dom Element to Represent the WSDL.But
> in this scenario we need to check the namespace and if it is a WSDL11
> Get the javax.wsl.Definition from the reader or else if it is WSDL20,
> serialize it and write it to a output stream so we can get it as a
> input stream
> to build a AxisService out of WSDL20.

This is just a suggestion from me for above case. cant you use Woden
with following approach ?

Instead of  -  if
(Constants.NS_URI_WSDL20.equals(documentElementNS.getNamespaceURI()))
check try to  use  Woden WSDLReader in the AxisService class.

  try{
       WSDLFactory factory = WSDLFactory.newInstance();
       WSDLReader reader = factory.newWSDLReader();
       reader.setFeature(ReaderFeatures.VALIDATION_FEATURE_ID, true);
       Description descComp = reader.readWSDL(wsdlLoc);
      }

 Once you have a org.apache.woden.wsdl20.Description instance you can
implement a method something like

 createClientSideAxisService(wsdlDescription,
wsdlServiceName,portName, options);

Also add new constructors to WSDL20ToAxisServiceBuilder so that it
will get org.apache.woden.wsdl20.Description as a argument like
WSDL11ToAxisServiceBuilder constructors getting javax.wsdl.Definition
as  arguments, this will eliminate  repetitive  parsing of same WSDL
document.

Thanks ,

On Tue, Mar 17, 2009 at 3:42 PM, keith chapman <ke...@gmail.com> wrote:
> I'm not sure how complete the AXIOM implementation is. The DOM is complete.
> I will ask this issue on the Woden list.
>
> Thanks,
> Keith.
>
> On Tue, Mar 17, 2009 at 4:24 AM, Andreas Veithen <an...@gmail.com>
> wrote:
>>
>> What about improving WSDL20ToAxisServiceBuilder to support DOM and/or
>> Axiom directly (I think Woden supports both)?
>>
>> Andreas
>>
>> On Mon, Mar 16, 2009 at 06:19, Pradeep Fernando <pr...@gmail.com>
>> wrote:
>> > Hi Devs,
>> >
>> > Right now Axis2 s' ServiceClient(Dynamic serviceClient) does not
>> > support WSDL2 as it argument. I did few changes to the Code and now it
>> > supports WSDL2 as well. But I would like to draw your attention
>> > regarding few issues.
>> >
>> > 1. In order to support both WSDL11 & WSDL20 without changing the
>> > method signature of the ServiceClient we need to identify the Given
>> > WSDL using the namespace.
>> >
>> > 2. In the current code It uses a dom Element to Represent the WSDL.But
>> > in this scenario we need to check the namespace and if it is a WSDL11
>> > Get the javax.wsl.Definition from the reader or else if it is WSDL20,
>> > serialize it and write it to a output stream so we can get it as a
>> > input stream
>> > to build a AxisService out of WSDL20.
>> >
>> > 3.since the current implementation uses dom element this mechanism
>> > results in a double parsing when its a WSDL20.possible solution is
>> > using
>> > Axiom instead of dom so that when namespace checking it does not parse
>> > the entire WSDL.
>> >
>> > 4. So i replaced Dom with Axiom and used Doom to create the Dom
>> > element out of Axiom element when need to fed to the readWSDL()
>> > method of the
>> > WSDL reader.
>> >
>> > WDYT devs? comments ,suggestions are mostly welcome.
>> > The patch related to this issue can be found in [1]
>> >
>> > Thanks in advance,
>> > Pradeep Fernando.
>> >
>> > [1] https://issues.apache.org/jira/browse/AXIS2-4253
>> >
>
>
>
> --
> Keith Chapman
> Senior Software Engineer
> WSO2 Inc.
> Oxygenating the Web Service Platform.
> http://wso2.org/
>
> blog: http://www.keith-chapman.org
>



-- 
Sagara Gunathunga

Blog - http://ssagara.blogspot.com
Web - http://sagaras.awardspace.com/

Re: using Axiom instead of DOM in ServiceClient.

Posted by keith chapman <ke...@gmail.com>.
I'm not sure how complete the AXIOM implementation is. The DOM is complete.
I will ask this issue on the Woden list.

Thanks,
Keith.

On Tue, Mar 17, 2009 at 4:24 AM, Andreas Veithen
<an...@gmail.com>wrote:

> What about improving WSDL20ToAxisServiceBuilder to support DOM and/or
> Axiom directly (I think Woden supports both)?
>
> Andreas
>
> On Mon, Mar 16, 2009 at 06:19, Pradeep Fernando <pr...@gmail.com>
> wrote:
> > Hi Devs,
> >
> > Right now Axis2 s' ServiceClient(Dynamic serviceClient) does not
> > support WSDL2 as it argument. I did few changes to the Code and now it
> > supports WSDL2 as well. But I would like to draw your attention
> > regarding few issues.
> >
> > 1. In order to support both WSDL11 & WSDL20 without changing the
> > method signature of the ServiceClient we need to identify the Given
> > WSDL using the namespace.
> >
> > 2. In the current code It uses a dom Element to Represent the WSDL.But
> > in this scenario we need to check the namespace and if it is a WSDL11
> > Get the javax.wsl.Definition from the reader or else if it is WSDL20,
> > serialize it and write it to a output stream so we can get it as a
> > input stream
> > to build a AxisService out of WSDL20.
> >
> > 3.since the current implementation uses dom element this mechanism
> > results in a double parsing when its a WSDL20.possible solution is
> > using
> > Axiom instead of dom so that when namespace checking it does not parse
> > the entire WSDL.
> >
> > 4. So i replaced Dom with Axiom and used Doom to create the Dom
> > element out of Axiom element when need to fed to the readWSDL()
> > method of the
> > WSDL reader.
> >
> > WDYT devs? comments ,suggestions are mostly welcome.
> > The patch related to this issue can be found in [1]
> >
> > Thanks in advance,
> > Pradeep Fernando.
> >
> > [1] https://issues.apache.org/jira/browse/AXIS2-4253
> >
>



-- 
Keith Chapman
Senior Software Engineer
WSO2 Inc.
Oxygenating the Web Service Platform.
http://wso2.org/

blog: http://www.keith-chapman.org

Re: using Axiom instead of DOM in ServiceClient.

Posted by Andreas Veithen <an...@gmail.com>.
What about improving WSDL20ToAxisServiceBuilder to support DOM and/or
Axiom directly (I think Woden supports both)?

Andreas

On Mon, Mar 16, 2009 at 06:19, Pradeep Fernando <pr...@gmail.com> wrote:
> Hi Devs,
>
> Right now Axis2 s' ServiceClient(Dynamic serviceClient) does not
> support WSDL2 as it argument. I did few changes to the Code and now it
> supports WSDL2 as well. But I would like to draw your attention
> regarding few issues.
>
> 1. In order to support both WSDL11 & WSDL20 without changing the
> method signature of the ServiceClient we need to identify the Given
> WSDL using the namespace.
>
> 2. In the current code It uses a dom Element to Represent the WSDL.But
> in this scenario we need to check the namespace and if it is a WSDL11
> Get the javax.wsl.Definition from the reader or else if it is WSDL20,
> serialize it and write it to a output stream so we can get it as a
> input stream
> to build a AxisService out of WSDL20.
>
> 3.since the current implementation uses dom element this mechanism
> results in a double parsing when its a WSDL20.possible solution is
> using
> Axiom instead of dom so that when namespace checking it does not parse
> the entire WSDL.
>
> 4. So i replaced Dom with Axiom and used Doom to create the Dom
> element out of Axiom element when need to fed to the readWSDL()
> method of the
> WSDL reader.
>
> WDYT devs? comments ,suggestions are mostly welcome.
> The patch related to this issue can be found in [1]
>
> Thanks in advance,
> Pradeep Fernando.
>
> [1] https://issues.apache.org/jira/browse/AXIS2-4253
>