axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benazech Cédric <Cedric.Benaz...@atosorigin.com>
Subject RE: how to choose bean attributes to publish in WSDL
Date Wed, 17 Apr 2002 14:21:58 GMT
Thx. I'll take a look asap.

I created an other serializer that is very similar to BeanSerializer.
The difference is that it uses the java.beans.Introspector instead of
ClassRep to search for bean fields.
But this solution is not very good : using the Introspector (and the
BeanInfo) , there is no more class hierarchy. I'm trying to solve the
problem but it is not simple. I'll keep you informed.

Cédric


-----Message d'origine-----
De : Tom Jordahl [mailto:tomj@macromedia.com]
Envoyé : mercredi 17 avril 2002 16:07
À : 'axis-dev@xml.apache.org'
Cc : 'Cedric.Benazech@atosorigin.com'
Objet : RE: how to choose bean attributes to publish in WSDL


Cédric,

Dims just made a change that might help you out in doing this work.  There
is now a BeanUtils class that centralizes the Property Descriptor collection
code.  See src/org/apache/axis/utils/BeanUtils.java

Keep us posted on your progress!

--
Tom Jordahl
Macromedia


-----Original Message-----
From: Benazech Cédric [mailto:Cedric.Benazech@atosorigin.com]
Sent: Friday, April 12, 2002 10:50 AM
To: 'axis-dev@xml.apache.org'
Subject: RE: how to choose bean attributes to publish in WSDL


I'm actually trying to do that ! ;)

But that's very dificult for me : I just started to look at the Axis Source
for three months and I encounter difficulties to correctly understand the
architecture choices and some classes utility (ClassRep versus TypeDesc
versus PropertDescriptor, for example).

I'll try to make something good. If it's good enough, I will send it !

Cédric


-----Message d'origine-----
De : Tom Jordahl [mailto:tomj@macromedia.com]
Envoyé : vendredi 12 avril 2002 16:35
À : 'axis-dev@xml.apache.org'
Objet : RE: how to choose bean attributes to publish in WSDL



I think that enhancing Axis to use the BeanInfo class would generally be
useful.  

Why don't you make the changes and we can see about integrating them in the
source.  It should be straight forward to enhance the Beasnserailzier to
check for the BeanInfo class, right?

Then you will have a) solved your issue and b) contributed to the project!

--
Tom Jordahl
Macromedia


-----Original Message-----
From: Benazech Cédric [mailto:Cedric.Benazech@atosorigin.com]
Sent: Friday, April 12, 2002 5:51 AM
To: 'axis-dev@xml.apache.org'
Subject: RE: how to choose bean attributes to publish in WSDL


Thanks a lot for all your answers. They are very helpful for me.

I understand the gain to use wrapper for the beans, but for the project I'm
working an, there are a lot of bean (!!) and it would be a hard work to
create (and maintain) such a redundancy. 

To avoid that, my idea is to create a class (extending the ClassRep class)
which will have the responsabity to describe javabeans. The behaviour of the
class would be to search for the BeanInfo of the bean class and if it
exists, to use the JavaBean Introspector (that will ask for the
getPropertyDescriptor method) to return the field Vector. The advantage is
that I only have to create BeanInfo class for each bean : that's a standard
way to describe Beans and the most of the work can be done automaticaly (by
using or building tools).  

The difficult part is that I want AxisServlet to use this class instead of
using the default ClassRep. Perhaps, I will have to create a copy of the
BeanSerializer/Deserializer that will use my version of ClassRep instead of
the Axis one.

What do you think of this functionnality ?
Then, to extend the debate, don't you think that BeanSerializer should use
the java.beans.Introspector to introspect the bean classes ?

Cédric


-----Message d'origine-----
De : Chris Haddad [mailto:chris.haddad@cobia.net]
Envoyé : jeudi 11 avril 2002 19:25
À : axis-dev@xml.apache.org
Objet : RE: how to choose bean attributes to publish in WSDL


Cedric - if you cannot modify the EJB class, I suggest you wrap it in a
class that is exposed by the web service. For example, Person.java would
be PersonWS.java

Wrapping has an extra benefit, it provides for a more loosely coupled
architecture between your public interface and the internal business
logic. There is an added benefit as well because the façade layer allows
upgrades to the core logic to be made behind the scene without changing
the external contract with your web service clients.

/Chris


-----Original Message-----
From: Benazech Cédric [mailto:Cedric.Benazech@atosorigin.com] 
Sent: Thursday, April 11, 2002 12:46 PM
To: 'axis-dev@xml.apache.org'
Subject: RE: how to choose bean attributes to publish in WSDL

thanks for your answer.

If I understand correctly, you ask me to delete the getter and setter
for
the attribute I don't want to see in the WSDL.
The problem is that I can not modify the beans : they are parts of a big
EJB
project (they are parameters and return types of EJB methods). In fact,
they
contain data I don't want to be written in the SOAP messages (for
example,
public static attributes, unnecessary data from classes extending the
bean,
etc ...).

So my question is, Is there a way to "list" the attribute of beans to
publish in the WSDL and to serialize ?
It seems to be an important feature, isn't it ? 

Cédric


-----Message d'origine-----
De : Peake, Chris [mailto:CHRIS.PEAKE@ca.com]
Envoyé : jeudi 11 avril 2002 18:14
À : axis-dev@xml.apache.org
Objet : RE: how to choose bean attributes to publish in WSDL


I haven't tried this but you should be able to make the 'name' private
modifier.
But leave the getter and setter methods.
I thought the 'ClassRep' has the 'addFields' which will do a
'getDeclaredFields' (i.e. private stuff too) and it will test these to
see
if 'normal' bean getter and setter fields are present for this field.
If
so, then the fields vector is updated and the WSDL <sequence> for this
<complexType> 'should' be updated.
I have not tested this but only reviewed the code but that is the way it
appears to behave.

I just took the time to try this and it works.

chris

-----Original Message-----
From: Benazech Cédric [mailto:Cedric.Benazech@atosorigin.com]
Sent: Thursday, April 11, 2002 10:58 AM
To: axis-dev@xml.apache.org
Subject: how to choose bean attributes to publish in WSDL


Hello.

Is there a simple way to choose the javabeans' attributes to display in
the
WSDL.
for example, I have this bean :

public class Personn { 
   private String name, firstname, surname;
   
   public String getName() { return name; }
   public String getFirstname() { return firstname; }
   public String getSurname() { return surname; }

   public void setName(String s) { name = s; }
   public void setFirstname(String s) { firstname = s; }
   public void setSurname(String s) { surname = s; }
}

By default, the generated XML Schema generated in the wsdl is :

<complexType name="SMSText">
 <sequence>
  <element name="name" nillable="true" type="xsd:string" /> 
  <element name="firstname" nillable="true" type="xsd:string" /> 
  <element name="surname" nillable="true" type="xsd:string" /> 
 </sequence>
</complexType>

How can I hide the surname, for example, in order to generate this
Schema : 
<complexType name="SMSText">
 <sequence>
  <element name="name" nillable="true" type="xsd:string" /> 
  <element name="firstname" nillable="true" type="xsd:string" /> 
 </sequence>
</complexType>


I searched a lot (in the Axis source) and tried several ways :
  - using a BeanInfo : that didn't work. The BeanSerializer doesn't use
the
java.bean.Introspector
  - writing a getAttribute() method in the bean : didn't work. This
feature
doesn't seems to be used anymore : the method is called in the
BeanSerializer.getBeanAttributes(Class, TypeDesc) but getBeanAttributes
is
not used in the BeanSerializer.writeSchema(Types) which is responsible
for
the WSDL generation
  - writing a getTypeDesc() methode in the bean : didn't work. I thaught
the
TypeDesc was used to describe a class, but It's the ClassRep object that
is
used to Introspect the Bean classes. I haven't understood what the
TypeDesc
is used for ... :(

The only way I see is to write an other BeanSerializer (hard to do ...)
or
to extend the addFields(Class) method of ClassRep, but I don't know how
to
make the AxisServlet use my version of ClassRep for the dynamic
generation
of the wsdl (with the ?wsdl in the URL).

Any help will be greatly appreciated.

- Cédric

PS : excuse my poor english : I'm French and not used to write English
...
;(

Mime
View raw message