axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benazech Cédric <>
Subject RE: how to choose bean attributes to publish in WSDL
Date Thu, 11 Apr 2002 16:46:18 GMT
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 ? 


-----Message d'origine-----
De : Peake, Chris []
Envoyé : jeudi 11 avril 2002 18:14
À :
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
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.


-----Original Message-----
From: Benazech Cédric []
Sent: Thursday, April 11, 2002 10:58 AM
Subject: how to choose bean attributes to publish in WSDL


Is there a simple way to choose the javabeans' attributes to display in the
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">
  <element name="name" nillable="true" type="xsd:string" /> 
  <element name="firstname" nillable="true" type="xsd:string" /> 
  <element name="surname" nillable="true" type="xsd:string" /> 

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

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
  - 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 ...

View raw message