The above are the points taken from this site http://blog.ibeesolutions.com/web-services-implementation-considerations.html
Serialization is an important issue from the web services’ performance point of view since web services uses XML in SOAP messages.
So Reduce Serialization with XmlIgnore
To limit which fields exposed by an object are serialized when the object is passed to or from a Web method and to reduce the amount of data sent over the wire, the XmlIgnore
attribute should be used as shown below.
The XmlSerializer
class ignores any field annotated with this attribute.
Please note that XmlIgnore
serializes only public members unlike the formatters derived from IFormatter
interface.
// This is the class that will be serialized.
public class MyClass
{
// The str1 value will be serialized.
public string str1;
/* This field will be ignored when serialized–
unless it’s overridden. */
[XmlIgnoreAttribute]
public string str2;
}
Here the author mentions about the tips on Inproving Webservices and on of them is to use XmlIgnoreAttribute
I have developed a Webservice using Java through Apache CXF Framework .
Please tell me how can I use that or any similar attribute with in Java Technology ??
Web Services implemented using JAX-WS (SOAP) or JAX-RS (RESTful) implementations use JAXB (JSR-222) for the binding layer. When using JAXB you can leverage the @XmlTransient
annotation to exclude a field/property from the XML representation.
For More Information
In java properties which shouldnt be serialized are marked as transient or you can implement Externalizable
interface instead of Serializable
and ignore fields which you don't want to be serialized in your readObject
and writeObject
method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With