Is there XmlIgnoreAttribute or equalvent in java technology

The above items are taken from this site http://blog.ibeesolutions.com/web-services-implementation-considerations.html

Serialization is an important issue in terms of web service performance because web services use XML in SOAP messages.

So reduce serialization with XmlIgnore

To limit which fields exposed by the object are serialized when the object is passed to or from the Web method, and to reduce the amount of data sent over the wire, use the XmlIgnore attribute, as shown below.

The XmlSerializer class ignores any field annotated with this attribute.

Note that XmlIgnore only serializes public elements, unlike formatters derived from the 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 Inproving Webservices tips, and XmlIgnoreAttribute should be used from them.

I developed Webservice using Java through the Apache CXF Framework.

Please tell me how can I use this or any similar attribute in Java Technology?

+4
source share
2 answers

Web services implemented using JAX-WS (SOAP) or JAX-RS (RESTful) implementations use JAXB (JSR-222) to bind the layer. When using JAXB, you can use the @XmlTransient annotation to exclude the field / property from the XML view.

Additional Information

+5
source

In java properties that should not be serialized, marked as transient, or you can implement the Externalizable interface instead of Serializable and ignore fields that you do not want to serialize in the readObject and writeObject .

+3
source

Source: https://habr.com/ru/post/1386494/


All Articles