Thank
you Tony. This is what I ended up doing yesterday - putting underscores in front
of the methods. Don't like it though, as technically by doing this I am in
violation of coding standards, and in general this isn't a clean solution.
I
actually thought I found a way to "tell" Axis that only properties of my choice
should be returned, and it did not work. Here's an example. In my class that
ends up being serialized, I set up this:
public
class SerializationTest
{
{
private static org.apache.axis.description.TypeDesc
typeDesc = null;
static
{
typeDesc = new org.apache.axis.description.TypeDesc(SerializationTest.class);
{
typeDesc = new org.apache.axis.description.TypeDesc(SerializationTest.class);
Vector container = new
Vector();
org.apache.axis.description.ElementDesc element1 = new
org.apache.axis.description.ElementDesc();
element1.setFieldName("field1");
element1.setXmlName(new javax.xml.namespace.QName("", "field1"));
element1.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
element1.setFieldName("field1");
element1.setXmlName(new javax.xml.namespace.QName("", "field1"));
element1.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
org.apache.axis.description.ElementDesc element2 = new org.apache.axis.description.ElementDesc();
element1.setFieldName("field2");
element1.setXmlName(new javax.xml.namespace.QName("", "field2"));
element1.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
container.add(element1);
container.add(element2);
container.add(element2);
typeDesc.setFields((org.apache.axis.description.FieldDesc[])container.toArray(new
org.apache.axis.description.FieldDesc[0]));
}
}
public static org.apache.axis.description.TypeDesc getTypeDesc()
{
return typeDesc;
}
//
rest of the code, including properties like getField1(), getField2() and so
on
...
}
}
In
debugger, I can see Axis calling getTypeDesc() and retuning the object that I
have constructed in the static initializer (with 2 fields only). But, when it
serializes it, additional properties appear on the response (that are not on the
WSDL either).
What
am I doing wrong? And, why properties that are not on the WSDL still being put
up in the response?
Thanks
Bogdan
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 23, 2004 2:41 AM
To: [EMAIL PROTECTED]
Subject: Re: hiding a property from Axis serializer?
I don't think there is any way of hiding properties explicitly. If you use a BeanSerializer, all properties that follow the JavaBean convention will be picked up. One way is to not use JavaBean conventions for those properties that you want to hide. Take a look at the JavaBean specification and see if you can modify the getter and setter methods for those properties so that they don't follow the convention. For example, if the methods don't need to be public, removing the public modifier, might do the trick.
If Axis made use of a BeanInfo class, you might be able to hide properties that way, but I think Axis just assumes the standard JavaBean conventions, without BeanInfo modification.
Otherwise, you'd probably have to write your own serializer (and you might still be able to use the BeanDeserializer at the other end).
Tony
"Sheptunov, Bogdan" <[EMAIL PROTECTED]> 22-Nov-2004 21:16
Hello,
Axis serializer by default picks up everything that looks like a JavaBean property, and puts it into response. This leads to an undesirable side effect: some of the class internals that have bean-like access, become exposed to the outside and end up being automatically included into the Soap response.
Is there a good way to avoid that, or to perhaps "hide" the properties of my choice from Axis, so that they would not be exposed automatically?
The effect I am seeing now is that some of my properties show up on the response object even if they are not declared in WSDL. How can this be?
I've look at org.apache.axis.description.TypeDesc, and thought of possibly removing a corresponding org.apache.axis.description.ElementDesc entity from there, but there's no any removal API. And the only ways to create org.apache.axis.description.TypeDesc() all require you to pass in a class (don't allow you to "build from scratch"), so you cannot really bulid the TypeDesc manually (so that I could only expose the properties I'd want).
Please advice.
Thanks
Bogdan
PS Axis 1.2 RC1.