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 Dobri Kitipov <kd...@googlemail.com> on 2008/02/04 16:22:27 UTC

Custom WSDL generation

Hi everybody,
There is one mail thread
http://marc.info/?l=axis-dev&m=118399944531093&w=2that talks about
using WSDLSupplier that gives you the possibility to hook
your own WSDL on the fly. This is done implementing an interface
org.apache.axis2.dataretrieval.WSDLSupplier.
What I am currently trying to do is to test this feature. I implemented my
own WSDLSupplier, but not sure how to specify it. Looking into the above
mentioned thread we can read:

"I added a check in printWSDL() to see if there was a WSDLSupplier sitting
in the "WSDLSupplier" parameter of the AxisService.  If so, it attempts to
call the WSDLSupplier to obtain the Definition object from there
dynamically.  It then runs that WSDL through the usual
printDefinitionObject() API.  This allows my custom service to plug in and
generate its own WSDL."

IMHO I should add a parameter into the services.xml file like:

<serviceGroup>
  <service name="Test1">
    <description>Web Service Test1</description>
    <parameter name="WSDLSupplier">com.test.wsdlsupplier.MyWSDLSupplier
</parameter>
    <messageReceivers>
      <messageReceiver class="
org.apache.axis2.rpc.receivers.RPCMessageReceiver" mep="
http://www.w3.org/2004/08/wsdl/in-out"/>
    </messageReceivers>
    <operation name="echo"/>
  </service>
</serviceGroup>

The problem is that into org.apache.axis2.description.AxisService method
public void printWSDL(OutputStream out, String requestIP) the check is:

WSDLSupplier supplier = (WSDLSupplier)getParameterValue("WSDLSupplier");

So I receive:
java.lang.ClassCastException: java.lang.String
    org.apache.axis2.description.AxisService.printWSDL(AxisService.java
:1167)
...

which is something expected because  getParameterValue("WSDLSupplier");
returns a String object, but not WSDLSupplier. So it is not possible to cast
String to WSDLSupplier.

Please, advise me how it should be done. I did not find anything that
explains this.

Thank you in advance!

Dobri

Re: Custom WSDL generation

Posted by Dobri Kitipov <kd...@googlemail.com>.
Hi Glen,
yes it sounds good. Anyway I was thinking of having more generic approach.
What about just to add a new attribute for parameter that will define the
type of the value (e.g. class, String, etc.) ?
Anyway if this is not possible at the moment I will expect the fix you are
suggesting.

Thank you!

Regards, Dobri

On Feb 6, 2008 8:25 AM, Glen Daniels <gl...@thoughtcraft.com> wrote:

> Hi Dobri:
>
> The WSDLSupplier, at least up until now, is something that gets added to
> the AxisService as a parameter programatically, not via configuration.
> The value is an actual WSDLSupplier, not a class name.  However this
> could certainly be changed, and I kind of like your idea for doing so.
>
> The one implementation of this we use in WSO2's Axis1Deployer (the link
> Saminda sent) has a specific constructor, because it needs to remember
> the active (Axis 1.4) AxisServer - so this is why we create it with
> custom code and insert it into the AxisService manually.  (However, we
> could just put the AxisServer reference into another parameter and have
> it look for that, and then it could have a default constructor)
>
> So here's my suggestion:
>
> Let's leave the "WSDLSupplier" parameter as it is - so if someone puts
> an implementation in the AxisService, that particular object gets used.
>  Then we add a "WSDLSupplierClass" parameter, which is expected to be a
> string classname.  If we find one of *those* (as in the config examples
> you have below), we'll create one using a default constructor, and if
> that succeeds we load the result into the "WSDLSupplier" param.
>
> Sound good?
>
> --Glen
>
> Dobri Kitipov wrote:
> > Hi Saminda,
> > I am not sure I get everything right. So let's clarify it.
> >
> > 1) My understanding is that I should create a JIRA about WSDLSupplier
> > parameter, right? But I think this is a more or less feature than a bug?
> > I mean, AFAIK when you add a parameter to services/axis2.xml it is
> > supposed to be retrieved as String? May be there is a need of an
> > additional new attribute like "type". E.g.:
> >
> > <parameter name="WSDLSupplier "
> > type="class">com.test.wsdlsupplier.MyWSDLSupplier</parameter>
> >
> > or for example something like specifing the deployer into axis2.xml:
> > <deployer extension=".class" directory="pojo"
> > class="org.apache.axis2.deployment.POJODeployer"/>
> >
> > or in our case
> >
> > <WSDLSupplier class="com.test.wsdlsupplier.MyWSDLSupplier"/> ?
> >
> > We need to think more deeply which one is preferable. But anyway I can
> > open a JIRA like this.
> >
> > Anyway the effect should be that in this case axis will know the type of
> > the artifact/parameter and will try to load it from the classpath.
> >
> > 2) I do not want to use "useOriginalWSDL", but dynamically generate and
> > provide the WSDL at server side based on some criteria. So my
> > understanding is that the mail thread
> > http://marc.info/?l=axis-dev&m=118399944531093&w=2
> > <http://marc.info/?l=axis-dev&m=118399944531093&w=2> considers exactly
> > this use case, providing the ability to hook an implementation of
> > WSDLSupplier  that should return the WSDL ? Am I wrong?
> > I will change the message receiver and have a look at the link you
> > provided to me.
> >
> > Thank you in advance!
> >
> > Dobri
> >
> > On Feb 5, 2008 10:41 AM, Saminda Abeyruwan <samindaa@gmail.com
> > <ma...@gmail.com>> wrote:
> >
> >     Hi Dobri,
> >
> >     In deed, if the parameter is defined as prior, it would cause a
> >     class cast exception. This should be fixed. The intended used case
> >     for WSDLSupplier is IMHO not what you have identified. You'll be
> >     able to find a use case in [1].
> >
> >     Since you are using
> >     org.apache.axis2.rpc.receivers.RPCMessageReceiver, this will
> >     generate the WSDL for your POJO. And if policy is applied, it will
> >     be correctly attached to the WSDL.
> >
> >     If you have a pre-defined WSDL, please use the parameter
> >
> >     <parameter name="useOrignalWSDL"> true </parameter>
> >
> >
> >     Where wsdl's endpoint should be named exactly as the service name.
> >     In this case "Test1".
> >
> >     Please do log a JIRA to prevent class cast exception.
> >
> >     Thank you
> >
> >     Saminda
> >
> >     Reference:
> >
> >     [1] .
> >
> https://wso2.org/repos/wso2/trunk/commons/deployers/axis1deployer/src/main/java/a1deployer/
> >
> >
> >
> >
> >
> >
> >
> >
> >     On Feb 4, 2008 8:52 PM, Dobri Kitipov <kdobrik.axis2@googlemail.com
> >     <ma...@googlemail.com>> wrote:
> >
> >         Hi everybody,
> >         There is one mail thread
> >         http://marc.info/?l=axis-dev&m=118399944531093&w=2
> >         <http://marc.info/?l=axis-dev&m=118399944531093&w=2> that talks
> >         about using WSDLSupplier that gives you the possibility to hook
> >         your own WSDL on the fly. This is done implementing an interface
> >         org.apache.axis2.dataretrieval.WSDLSupplier.
> >         What I am currently trying to do is to test this feature. I
> >         implemented my own WSDLSupplier, but not sure how to specify it.
> >         Looking into the above mentioned thread we can read:
> >
> >         "I added a check in printWSDL() to see if there was a
> >         WSDLSupplier sitting in the "WSDLSupplier" parameter of the
> >         AxisService.  If so, it attempts to call the WSDLSupplier to
> >         obtain the Definition object from there dynamically.  It then
> >         runs that WSDL through the usual printDefinitionObject() API.
> >         This allows my custom service to plug in and generate its own
> WSDL."
> >
> >         IMHO I should add a parameter into the services.xml file like:
> >
> >         <serviceGroup>
> >           <service name="Test1">
> >             <description>Web Service Test1</description>
> >             <parameter
> >         name="WSDLSupplier">com.test.wsdlsupplier.MyWSDLSupplier
> </parameter>
> >             <messageReceivers>
> >               <messageReceiver
> >         class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"
> >         mep="http://www.w3.org/2004/08/wsdl/in-out"/>
> >             </messageReceivers>
> >             <operation name="echo"/>
> >           </service>
> >         </serviceGroup>
> >
> >         The problem is that into
> >         org.apache.axis2.description.AxisService method public void
> >         printWSDL(OutputStream out, String requestIP) the check is:
> >
> >         WSDLSupplier supplier =
> >         (WSDLSupplier)getParameterValue("WSDLSupplier");
> >
> >         So I receive:
> >         java.lang.ClassCastException: java.lang.String
> >
> >         org.apache.axis2.description.AxisService.printWSDL(
> AxisService.java:1167)
> >         ...
> >
> >         which is something expected because
> >         getParameterValue("WSDLSupplier"); returns a String object, but
> >         not WSDLSupplier. So it is not possible to cast String to
> >         WSDLSupplier.
> >
> >         Please, advise me how it should be done. I did not find anything
> >         that explains this.
> >
> >         Thank you in advance!
> >
> >         Dobri
> >
> >
> >
> >
> >     --
> >     Saminda Abeyruwan
> >
> >     Senior Software Engineer
> >     WSO2 Inc. - www.wso2.org <http://www.wso2.org>
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-dev-help@ws.apache.org
>
>

Re: Custom WSDL generation

Posted by Sanka Samaranayake <ss...@gmail.com>.
Hi Glen,

Axis2 Data Retrieval[1] architecture allows you to write your own custom
WSDL Data Locator which will give you the freedom to control WSDL generation
as you wish. Doesn't it work for you in the following case[2]

Cheers,
--Sanka


[1]
https://svn.apache.org/repos/asf/webservices/axis2/trunk/java/modules/samples/mex/
[2] http://marc.info/?l=axis-dev&m=118399944531093&w=2


On Feb 6, 2008 11:55 AM, Glen Daniels <gl...@thoughtcraft.com> wrote:

> Hi Dobri:
>
> The WSDLSupplier, at least up until now, is something that gets added to
> the AxisService as a parameter programatically, not via configuration.
> The value is an actual WSDLSupplier, not a class name.  However this
> could certainly be changed, and I kind of like your idea for doing so.
>
> The one implementation of this we use in WSO2's Axis1Deployer (the link
> Saminda sent) has a specific constructor, because it needs to remember
> the active (Axis 1.4) AxisServer - so this is why we create it with
> custom code and insert it into the AxisService manually.  (However, we
> could just put the AxisServer reference into another parameter and have
> it look for that, and then it could have a default constructor)
>
> So here's my suggestion:
>
> Let's leave the "WSDLSupplier" parameter as it is - so if someone puts
> an implementation in the AxisService, that particular object gets used.
>  Then we add a "WSDLSupplierClass" parameter, which is expected to be a
> string classname.  If we find one of *those* (as in the config examples
> you have below), we'll create one using a default constructor, and if
> that succeeds we load the result into the "WSDLSupplier" param.
>
> Sound good?
>
> --Glen
>
> Dobri Kitipov wrote:
> > Hi Saminda,
> > I am not sure I get everything right. So let's clarify it.
> >
> > 1) My understanding is that I should create a JIRA about WSDLSupplier
> > parameter, right? But I think this is a more or less feature than a bug?
> > I mean, AFAIK when you add a parameter to services/axis2.xml it is
> > supposed to be retrieved as String? May be there is a need of an
> > additional new attribute like "type". E.g.:
> >
> > <parameter name="WSDLSupplier "
> > type="class">com.test.wsdlsupplier.MyWSDLSupplier</parameter>
> >
> > or for example something like specifing the deployer into axis2.xml:
> > <deployer extension=".class" directory="pojo"
> > class="org.apache.axis2.deployment.POJODeployer"/>
> >
> > or in our case
> >
> > <WSDLSupplier class="com.test.wsdlsupplier.MyWSDLSupplier"/> ?
> >
> > We need to think more deeply which one is preferable. But anyway I can
> > open a JIRA like this.
> >
> > Anyway the effect should be that in this case axis will know the type of
> > the artifact/parameter and will try to load it from the classpath.
> >
> > 2) I do not want to use "useOriginalWSDL", but dynamically generate and
> > provide the WSDL at server side based on some criteria. So my
> > understanding is that the mail thread
> > http://marc.info/?l=axis-dev&m=118399944531093&w=2
> > <http://marc.info/?l=axis-dev&m=118399944531093&w=2> considers exactly
> > this use case, providing the ability to hook an implementation of
> > WSDLSupplier  that should return the WSDL ? Am I wrong?
> > I will change the message receiver and have a look at the link you
> > provided to me.
> >
> > Thank you in advance!
> >
> > Dobri
> >
> > On Feb 5, 2008 10:41 AM, Saminda Abeyruwan <samindaa@gmail.com
> > <ma...@gmail.com>> wrote:
> >
> >     Hi Dobri,
> >
> >     In deed, if the parameter is defined as prior, it would cause a
> >     class cast exception. This should be fixed. The intended used case
> >     for WSDLSupplier is IMHO not what you have identified. You'll be
> >     able to find a use case in [1].
> >
> >     Since you are using
> >     org.apache.axis2.rpc.receivers.RPCMessageReceiver, this will
> >     generate the WSDL for your POJO. And if policy is applied, it will
> >     be correctly attached to the WSDL.
> >
> >     If you have a pre-defined WSDL, please use the parameter
> >
> >     <parameter name="useOrignalWSDL"> true </parameter>
> >
> >
> >     Where wsdl's endpoint should be named exactly as the service name.
> >     In this case "Test1".
> >
> >     Please do log a JIRA to prevent class cast exception.
> >
> >     Thank you
> >
> >     Saminda
> >
> >     Reference:
> >
> >     [1] .
> >
> https://wso2.org/repos/wso2/trunk/commons/deployers/axis1deployer/src/main/java/a1deployer/
> >
> >
> >
> >
> >
> >
> >
> >
> >     On Feb 4, 2008 8:52 PM, Dobri Kitipov <kdobrik.axis2@googlemail.com
> >     <ma...@googlemail.com>> wrote:
> >
> >         Hi everybody,
> >         There is one mail thread
> >         http://marc.info/?l=axis-dev&m=118399944531093&w=2
> >         <http://marc.info/?l=axis-dev&m=118399944531093&w=2> that talks
> >         about using WSDLSupplier that gives you the possibility to hook
> >         your own WSDL on the fly. This is done implementing an interface
> >         org.apache.axis2.dataretrieval.WSDLSupplier.
> >         What I am currently trying to do is to test this feature. I
> >         implemented my own WSDLSupplier, but not sure how to specify it.
> >         Looking into the above mentioned thread we can read:
> >
> >         "I added a check in printWSDL() to see if there was a
> >         WSDLSupplier sitting in the "WSDLSupplier" parameter of the
> >         AxisService.  If so, it attempts to call the WSDLSupplier to
> >         obtain the Definition object from there dynamically.  It then
> >         runs that WSDL through the usual printDefinitionObject() API.
> >         This allows my custom service to plug in and generate its own
> WSDL."
> >
> >         IMHO I should add a parameter into the services.xml file like:
> >
> >         <serviceGroup>
> >           <service name="Test1">
> >             <description>Web Service Test1</description>
> >             <parameter
> >         name="WSDLSupplier">com.test.wsdlsupplier.MyWSDLSupplier
> </parameter>
> >             <messageReceivers>
> >               <messageReceiver
> >         class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"
> >         mep="http://www.w3.org/2004/08/wsdl/in-out"/>
> >             </messageReceivers>
> >             <operation name="echo"/>
> >           </service>
> >         </serviceGroup>
> >
> >         The problem is that into
> >         org.apache.axis2.description.AxisService method public void
> >         printWSDL(OutputStream out, String requestIP) the check is:
> >
> >         WSDLSupplier supplier =
> >         (WSDLSupplier)getParameterValue("WSDLSupplier");
> >
> >         So I receive:
> >         java.lang.ClassCastException: java.lang.String
> >
> >         org.apache.axis2.description.AxisService.printWSDL(
> AxisService.java:1167)
> >         ...
> >
> >         which is something expected because
> >         getParameterValue("WSDLSupplier"); returns a String object, but
> >         not WSDLSupplier. So it is not possible to cast String to
> >         WSDLSupplier.
> >
> >         Please, advise me how it should be done. I did not find anything
> >         that explains this.
> >
> >         Thank you in advance!
> >
> >         Dobri
> >
> >
> >
> >
> >     --
> >     Saminda Abeyruwan
> >
> >     Senior Software Engineer
> >     WSO2 Inc. - www.wso2.org <http://www.wso2.org>
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-dev-help@ws.apache.org
>
>


-- 
Sanka Samaranayake
WSO2 Inc.

http://sankas.blogspot.com/
http://www.wso2.org/

Re: Custom WSDL generation

Posted by Dobri Kitipov <kd...@googlemail.com>.
Hi Glen,
I have opened the JIRA: https://issues.apache.org/jira/browse/AXIS2-3492
But I am not sure how do you think is the right way to associate a
WSDLSupplier implementation with a given AxisService?
Do you suggest me to use the AxisDescription addParameter(String name,
Object value) method? If so I am not sure when this should happen. One
possible time is to do that at deployment time (as suggested into the
example you have provided [1]). The problem is that if you restart the
server/application this parameter will be lost?
IMHO in the common case this WSDLSupplier implementation should be part of
the AAR, right? In this case I think the best way to add the WSDLSupplier
implementation is to have it as a param into the services.xml and have a
custom code(somewhere I am not yet sure where) to load its String
representation as an real Object using reflection.

Any advices are appreciated.

Thank you in advance,
Dobri

reference:
[1] .
https://wso2.org/repos/wso2/trunk/commons/deployers/axis1deployer/src/main/java/a1deployer/

Best Regards, Dobrir

On Feb 6, 2008 8:25 AM, Glen Daniels <gl...@thoughtcraft.com> wrote:

> Hi Dobri:
>
> The WSDLSupplier, at least up until now, is something that gets added to
> the AxisService as a parameter programatically, not via configuration.
> The value is an actual WSDLSupplier, not a class name.  However this
> could certainly be changed, and I kind of like your idea for doing so.
>
> The one implementation of this we use in WSO2's Axis1Deployer (the link
> Saminda sent) has a specific constructor, because it needs to remember
> the active (Axis 1.4) AxisServer - so this is why we create it with
> custom code and insert it into the AxisService manually.  (However, we
> could just put the AxisServer reference into another parameter and have
> it look for that, and then it could have a default constructor)
>
> So here's my suggestion:
>
> Let's leave the "WSDLSupplier" parameter as it is - so if someone puts
> an implementation in the AxisService, that particular object gets used.
>  Then we add a "WSDLSupplierClass" parameter, which is expected to be a
> string classname.  If we find one of *those* (as in the config examples
> you have below), we'll create one using a default constructor, and if
> that succeeds we load the result into the "WSDLSupplier" param.
>
> Sound good?
>
> --Glen
>
> Dobri Kitipov wrote:
> > Hi Saminda,
> > I am not sure I get everything right. So let's clarify it.
> >
> > 1) My understanding is that I should create a JIRA about WSDLSupplier
> > parameter, right? But I think this is a more or less feature than a bug?
> > I mean, AFAIK when you add a parameter to services/axis2.xml it is
> > supposed to be retrieved as String? May be there is a need of an
> > additional new attribute like "type". E.g.:
> >
> > <parameter name="WSDLSupplier "
> > type="class">com.test.wsdlsupplier.MyWSDLSupplier</parameter>
> >
> > or for example something like specifing the deployer into axis2.xml:
> > <deployer extension=".class" directory="pojo"
> > class="org.apache.axis2.deployment.POJODeployer"/>
> >
> > or in our case
> >
> > <WSDLSupplier class="com.test.wsdlsupplier.MyWSDLSupplier"/> ?
> >
> > We need to think more deeply which one is preferable. But anyway I can
> > open a JIRA like this.
> >
> > Anyway the effect should be that in this case axis will know the type of
> > the artifact/parameter and will try to load it from the classpath.
> >
> > 2) I do not want to use "useOriginalWSDL", but dynamically generate and
> > provide the WSDL at server side based on some criteria. So my
> > understanding is that the mail thread
> > http://marc.info/?l=axis-dev&m=118399944531093&w=2
> > <http://marc.info/?l=axis-dev&m=118399944531093&w=2> considers exactly
> > this use case, providing the ability to hook an implementation of
> > WSDLSupplier  that should return the WSDL ? Am I wrong?
> > I will change the message receiver and have a look at the link you
> > provided to me.
> >
> > Thank you in advance!
> >
> > Dobri
> >
> > On Feb 5, 2008 10:41 AM, Saminda Abeyruwan <samindaa@gmail.com
> > <ma...@gmail.com>> wrote:
> >
> >     Hi Dobri,
> >
> >     In deed, if the parameter is defined as prior, it would cause a
> >     class cast exception. This should be fixed. The intended used case
> >     for WSDLSupplier is IMHO not what you have identified. You'll be
> >     able to find a use case in [1].
> >
> >     Since you are using
> >     org.apache.axis2.rpc.receivers.RPCMessageReceiver, this will
> >     generate the WSDL for your POJO. And if policy is applied, it will
> >     be correctly attached to the WSDL.
> >
> >     If you have a pre-defined WSDL, please use the parameter
> >
> >     <parameter name="useOrignalWSDL"> true </parameter>
> >
> >
> >     Where wsdl's endpoint should be named exactly as the service name.
> >     In this case "Test1".
> >
> >     Please do log a JIRA to prevent class cast exception.
> >
> >     Thank you
> >
> >     Saminda
> >
> >     Reference:
> >
> >     [1] .
> >
> https://wso2.org/repos/wso2/trunk/commons/deployers/axis1deployer/src/main/java/a1deployer/
> >
> >
> >
> >
> >
> >
> >
> >
> >     On Feb 4, 2008 8:52 PM, Dobri Kitipov <kdobrik.axis2@googlemail.com
> >     <ma...@googlemail.com>> wrote:
> >
> >         Hi everybody,
> >         There is one mail thread
> >         http://marc.info/?l=axis-dev&m=118399944531093&w=2
> >         <http://marc.info/?l=axis-dev&m=118399944531093&w=2> that talks
> >         about using WSDLSupplier that gives you the possibility to hook
> >         your own WSDL on the fly. This is done implementing an interface
> >         org.apache.axis2.dataretrieval.WSDLSupplier.
> >         What I am currently trying to do is to test this feature. I
> >         implemented my own WSDLSupplier, but not sure how to specify it.
> >         Looking into the above mentioned thread we can read:
> >
> >         "I added a check in printWSDL() to see if there was a
> >         WSDLSupplier sitting in the "WSDLSupplier" parameter of the
> >         AxisService.  If so, it attempts to call the WSDLSupplier to
> >         obtain the Definition object from there dynamically.  It then
> >         runs that WSDL through the usual printDefinitionObject() API.
> >         This allows my custom service to plug in and generate its own
> WSDL."
> >
> >         IMHO I should add a parameter into the services.xml file like:
> >
> >         <serviceGroup>
> >           <service name="Test1">
> >             <description>Web Service Test1</description>
> >             <parameter
> >         name="WSDLSupplier">com.test.wsdlsupplier.MyWSDLSupplier
> </parameter>
> >             <messageReceivers>
> >               <messageReceiver
> >         class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"
> >         mep="http://www.w3.org/2004/08/wsdl/in-out"/>
> >             </messageReceivers>
> >             <operation name="echo"/>
> >           </service>
> >         </serviceGroup>
> >
> >         The problem is that into
> >         org.apache.axis2.description.AxisService method public void
> >         printWSDL(OutputStream out, String requestIP) the check is:
> >
> >         WSDLSupplier supplier =
> >         (WSDLSupplier)getParameterValue("WSDLSupplier");
> >
> >         So I receive:
> >         java.lang.ClassCastException: java.lang.String
> >
> >         org.apache.axis2.description.AxisService.printWSDL(
> AxisService.java:1167)
> >         ...
> >
> >         which is something expected because
> >         getParameterValue("WSDLSupplier"); returns a String object, but
> >         not WSDLSupplier. So it is not possible to cast String to
> >         WSDLSupplier.
> >
> >         Please, advise me how it should be done. I did not find anything
> >         that explains this.
> >
> >         Thank you in advance!
> >
> >         Dobri
> >
> >
> >
> >
> >     --
> >     Saminda Abeyruwan
> >
> >     Senior Software Engineer
> >     WSO2 Inc. - www.wso2.org <http://www.wso2.org>
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-dev-help@ws.apache.org
>
>

Re: Custom WSDL generation

Posted by Glen Daniels <gl...@thoughtcraft.com>.
Hi Dobri:

The WSDLSupplier, at least up until now, is something that gets added to 
the AxisService as a parameter programatically, not via configuration. 
The value is an actual WSDLSupplier, not a class name.  However this 
could certainly be changed, and I kind of like your idea for doing so.

The one implementation of this we use in WSO2's Axis1Deployer (the link 
Saminda sent) has a specific constructor, because it needs to remember 
the active (Axis 1.4) AxisServer - so this is why we create it with 
custom code and insert it into the AxisService manually.  (However, we 
could just put the AxisServer reference into another parameter and have 
it look for that, and then it could have a default constructor)

So here's my suggestion:

Let's leave the "WSDLSupplier" parameter as it is - so if someone puts 
an implementation in the AxisService, that particular object gets used. 
  Then we add a "WSDLSupplierClass" parameter, which is expected to be a 
string classname.  If we find one of *those* (as in the config examples 
you have below), we'll create one using a default constructor, and if 
that succeeds we load the result into the "WSDLSupplier" param.

Sound good?

--Glen

Dobri Kitipov wrote:
> Hi Saminda,
> I am not sure I get everything right. So let's clarify it.
> 
> 1) My understanding is that I should create a JIRA about WSDLSupplier 
> parameter, right? But I think this is a more or less feature than a bug? 
> I mean, AFAIK when you add a parameter to services/axis2.xml it is 
> supposed to be retrieved as String? May be there is a need of an 
> additional new attribute like "type". E.g.:
> 
> <parameter name="WSDLSupplier " 
> type="class">com.test.wsdlsupplier.MyWSDLSupplier</parameter>
> 
> or for example something like specifing the deployer into axis2.xml:
> <deployer extension=".class" directory="pojo" 
> class="org.apache.axis2.deployment.POJODeployer"/>
> 
> or in our case
> 
> <WSDLSupplier class="com.test.wsdlsupplier.MyWSDLSupplier"/> ?
> 
> We need to think more deeply which one is preferable. But anyway I can 
> open a JIRA like this.
> 
> Anyway the effect should be that in this case axis will know the type of 
> the artifact/parameter and will try to load it from the classpath.
> 
> 2) I do not want to use "useOriginalWSDL", but dynamically generate and 
> provide the WSDL at server side based on some criteria. So my 
> understanding is that the mail thread 
> http://marc.info/?l=axis-dev&m=118399944531093&w=2 
> <http://marc.info/?l=axis-dev&m=118399944531093&w=2> considers exactly 
> this use case, providing the ability to hook an implementation of 
> WSDLSupplier  that should return the WSDL ? Am I wrong?
> I will change the message receiver and have a look at the link you 
> provided to me.
> 
> Thank you in advance!
> 
> Dobri
> 
> On Feb 5, 2008 10:41 AM, Saminda Abeyruwan <samindaa@gmail.com 
> <ma...@gmail.com>> wrote:
> 
>     Hi Dobri,
> 
>     In deed, if the parameter is defined as prior, it would cause a
>     class cast exception. This should be fixed. The intended used case
>     for WSDLSupplier is IMHO not what you have identified. You'll be
>     able to find a use case in [1].
> 
>     Since you are using
>     org.apache.axis2.rpc.receivers.RPCMessageReceiver, this will
>     generate the WSDL for your POJO. And if policy is applied, it will
>     be correctly attached to the WSDL.
> 
>     If you have a pre-defined WSDL, please use the parameter
> 
>     <parameter name="useOrignalWSDL"> true </parameter>
> 
> 
>     Where wsdl's endpoint should be named exactly as the service name. 
>     In this case "Test1".
> 
>     Please do log a JIRA to prevent class cast exception.
> 
>     Thank you
> 
>     Saminda
> 
>     Reference:
> 
>     [1] .
>     https://wso2.org/repos/wso2/trunk/commons/deployers/axis1deployer/src/main/java/a1deployer/
> 
> 
> 
> 
> 
> 
> 
> 
>     On Feb 4, 2008 8:52 PM, Dobri Kitipov <kdobrik.axis2@googlemail.com
>     <ma...@googlemail.com>> wrote:
> 
>         Hi everybody,
>         There is one mail thread
>         http://marc.info/?l=axis-dev&m=118399944531093&w=2
>         <http://marc.info/?l=axis-dev&m=118399944531093&w=2> that talks
>         about using WSDLSupplier that gives you the possibility to hook
>         your own WSDL on the fly. This is done implementing an interface
>         org.apache.axis2.dataretrieval.WSDLSupplier.
>         What I am currently trying to do is to test this feature. I
>         implemented my own WSDLSupplier, but not sure how to specify it.
>         Looking into the above mentioned thread we can read:
> 
>         "I added a check in printWSDL() to see if there was a
>         WSDLSupplier sitting in the "WSDLSupplier" parameter of the
>         AxisService.  If so, it attempts to call the WSDLSupplier to
>         obtain the Definition object from there dynamically.  It then
>         runs that WSDL through the usual printDefinitionObject() API. 
>         This allows my custom service to plug in and generate its own WSDL."
> 
>         IMHO I should add a parameter into the services.xml file like:
> 
>         <serviceGroup>
>           <service name="Test1">
>             <description>Web Service Test1</description>
>             <parameter
>         name="WSDLSupplier">com.test.wsdlsupplier.MyWSDLSupplier</parameter>
>             <messageReceivers>
>               <messageReceiver
>         class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"
>         mep="http://www.w3.org/2004/08/wsdl/in-out"/>
>             </messageReceivers>
>             <operation name="echo"/>
>           </service>
>         </serviceGroup>
> 
>         The problem is that into
>         org.apache.axis2.description.AxisService method public void
>         printWSDL(OutputStream out, String requestIP) the check is:
> 
>         WSDLSupplier supplier =
>         (WSDLSupplier)getParameterValue("WSDLSupplier");
> 
>         So I receive:
>         java.lang.ClassCastException: java.lang.String
>            
>         org.apache.axis2.description.AxisService.printWSDL(AxisService.java:1167)
>         ...
> 
>         which is something expected because 
>         getParameterValue("WSDLSupplier"); returns a String object, but
>         not WSDLSupplier. So it is not possible to cast String to
>         WSDLSupplier.
> 
>         Please, advise me how it should be done. I did not find anything
>         that explains this.
> 
>         Thank you in advance!
> 
>         Dobri
> 
> 
> 
> 
>     -- 
>     Saminda Abeyruwan
> 
>     Senior Software Engineer
>     WSO2 Inc. - www.wso2.org <http://www.wso2.org> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


Re: Custom WSDL generation

Posted by Dobri Kitipov <kd...@googlemail.com>.
Hi Saminda,
I am not sure I get everything right. So let's clarify it.

1) My understanding is that I should create a JIRA about WSDLSupplier
parameter, right? But I think this is a more or less feature than a bug? I
mean, AFAIK when you add a parameter to services/axis2.xml it is supposed to
be retrieved as String? May be there is a need of an additional new
attribute like "type". E.g.:

<parameter name="WSDLSupplier " type="class">
com.test.wsdlsupplier.MyWSDLSupplier</parameter>

or for example something like specifing the deployer into axis2.xml:
<deployer extension=".class" directory="pojo" class="
org.apache.axis2.deployment.POJODeployer"/>

or in our case

<WSDLSupplier class="com.test.wsdlsupplier.MyWSDLSupplier"/> ?

We need to think more deeply which one is preferable. But anyway I can open
a JIRA like this.

Anyway the effect should be that in this case axis will know the type of the
artifact/parameter and will try to load it from the classpath.

2) I do not want to use "useOriginalWSDL", but dynamically generate and
provide the WSDL at server side based on some criteria. So my understanding
is that the mail thread
http://marc.info/?l=axis-dev&m=118399944531093&w=2considers exactly
this use case, providing the ability to hook an
implementation of WSDLSupplier  that should return the WSDL ? Am I wrong?
I will change the message receiver and have a look at the link you provided
to me.

Thank you in advance!

Dobri

On Feb 5, 2008 10:41 AM, Saminda Abeyruwan <sa...@gmail.com> wrote:

> Hi Dobri,
>
> In deed, if the parameter is defined as prior, it would cause a class cast
> exception. This should be fixed. The intended used case for WSDLSupplier is
> IMHO not what you have identified. You'll be able to find a use case in [1].
>
>
> Since you are using org.apache.axis2.rpc.receivers.RPCMessageReceiver,
> this will generate the WSDL for your POJO. And if policy is applied, it will
> be correctly attached to the WSDL.
>
> If you have a pre-defined WSDL, please use the parameter
>
> <parameter name="useOrignalWSDL"> true </parameter>
>
>
> Where wsdl's endpoint should be named exactly as the service name.  In
> this case "Test1".
>
> Please do log a JIRA to prevent class cast exception.
>
> Thank you
>
> Saminda
>
> Reference:
>
> [1] .
> https://wso2.org/repos/wso2/trunk/commons/deployers/axis1deployer/src/main/java/a1deployer/
>
>
>
>
>
>
>
>
> On Feb 4, 2008 8:52 PM, Dobri Kitipov <kd...@googlemail.com>
> wrote:
>
> > Hi everybody,
> > There is one mail thread
> > http://marc.info/?l=axis-dev&m=118399944531093&w=2 that talks about
> > using WSDLSupplier that gives you the possibility to hook your own WSDL on
> > the fly. This is done implementing an interface
> > org.apache.axis2.dataretrieval.WSDLSupplier.
> > What I am currently trying to do is to test this feature. I implemented
> > my own WSDLSupplier, but not sure how to specify it. Looking into the above
> > mentioned thread we can read:
> >
> > "I added a check in printWSDL() to see if there was a WSDLSupplier
> > sitting in the "WSDLSupplier" parameter of the AxisService.  If so, it
> > attempts to call the WSDLSupplier to obtain the Definition object from there
> > dynamically.  It then runs that WSDL through the usual
> > printDefinitionObject() API.  This allows my custom service to plug in and
> > generate its own WSDL."
> >
> > IMHO I should add a parameter into the services.xml file like:
> >
> > <serviceGroup>
> >   <service name="Test1">
> >     <description>Web Service Test1</description>
> >     <parameter name="WSDLSupplier">com.test.wsdlsupplier.MyWSDLSupplier
> > </parameter>
> >     <messageReceivers>
> >       <messageReceiver class="
> > org.apache.axis2.rpc.receivers.RPCMessageReceiver" mep="
> > http://www.w3.org/2004/08/wsdl/in-out"/>
> >     </messageReceivers>
> >     <operation name="echo"/>
> >   </service>
> > </serviceGroup>
> >
> > The problem is that into org.apache.axis2.description.AxisService method
> > public void printWSDL(OutputStream out, String requestIP) the check is:
> >
> > WSDLSupplier supplier = (WSDLSupplier)getParameterValue("WSDLSupplier");
> >
> > So I receive:
> > java.lang.ClassCastException: java.lang.String
> >     org.apache.axis2.description.AxisService.printWSDL(AxisService.java
> > :1167)
> > ...
> >
> > which is something expected because  getParameterValue("WSDLSupplier");
> > returns a String object, but not WSDLSupplier. So it is not possible to cast
> > String to WSDLSupplier.
> >
> > Please, advise me how it should be done. I did not find anything that
> > explains this.
> >
> > Thank you in advance!
> >
> > Dobri
> >
> >
>
>
> --
> Saminda Abeyruwan
>
> Senior Software Engineer
> WSO2 Inc. - www.wso2.org

Re: Custom WSDL generation

Posted by Saminda Abeyruwan <sa...@gmail.com>.
Hi Dobri,

In deed, if the parameter is defined as prior, it would cause a class cast
exception. This should be fixed. The intended used case for WSDLSupplier is
IMHO not what you have identified. You'll be able to find a use case in [1].


Since you are using org.apache.axis2.rpc.receivers.RPCMessageReceiver, this
will generate the WSDL for your POJO. And if policy is applied, it will be
correctly attached to the WSDL.

If you have a pre-defined WSDL, please use the parameter

<parameter name="useOrignalWSDL"> true </parameter>


Where wsdl's endpoint should be named exactly as the service name.  In this
case "Test1".

Please do log a JIRA to prevent class cast exception.

Thank you

Saminda

Reference:

[1] .
https://wso2.org/repos/wso2/trunk/commons/deployers/axis1deployer/src/main/java/a1deployer/







On Feb 4, 2008 8:52 PM, Dobri Kitipov <kd...@googlemail.com> wrote:

> Hi everybody,
> There is one mail thread
> http://marc.info/?l=axis-dev&m=118399944531093&w=2 that talks about using
> WSDLSupplier that gives you the possibility to hook your own WSDL on the
> fly. This is done implementing an interface
> org.apache.axis2.dataretrieval.WSDLSupplier.
> What I am currently trying to do is to test this feature. I implemented my
> own WSDLSupplier, but not sure how to specify it. Looking into the above
> mentioned thread we can read:
>
> "I added a check in printWSDL() to see if there was a WSDLSupplier sitting
> in the "WSDLSupplier" parameter of the AxisService.  If so, it attempts to
> call the WSDLSupplier to obtain the Definition object from there
> dynamically.  It then runs that WSDL through the usual
> printDefinitionObject() API.  This allows my custom service to plug in and
> generate its own WSDL."
>
> IMHO I should add a parameter into the services.xml file like:
>
> <serviceGroup>
>   <service name="Test1">
>     <description>Web Service Test1</description>
>     <parameter name="WSDLSupplier">com.test.wsdlsupplier.MyWSDLSupplier
> </parameter>
>     <messageReceivers>
>       <messageReceiver class="
> org.apache.axis2.rpc.receivers.RPCMessageReceiver" mep="
> http://www.w3.org/2004/08/wsdl/in-out"/>
>     </messageReceivers>
>     <operation name="echo"/>
>   </service>
> </serviceGroup>
>
> The problem is that into org.apache.axis2.description.AxisService method
> public void printWSDL(OutputStream out, String requestIP) the check is:
>
> WSDLSupplier supplier = (WSDLSupplier)getParameterValue("WSDLSupplier");
>
> So I receive:
> java.lang.ClassCastException: java.lang.String
>     org.apache.axis2.description.AxisService.printWSDL(AxisService.java
> :1167)
> ...
>
> which is something expected because  getParameterValue("WSDLSupplier");
> returns a String object, but not WSDLSupplier. So it is not possible to cast
> String to WSDLSupplier.
>
> Please, advise me how it should be done. I did not find anything that
> explains this.
>
> Thank you in advance!
>
> Dobri
>
>


-- 
Saminda Abeyruwan

Senior Software Engineer
WSO2 Inc. - www.wso2.org