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:[EMAIL PROTECTED]]
Sent: Thursday, April 11, 2002 10:58 AM
To: [EMAIL PROTECTED]
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 ...
;(

Reply via email to