Paw*_*wan 4 java xml performance xml-serialization
以上是本网站的观点 http://blog.ibeesolutions.com/web-services-implementation-considerations.html
从Web服务的性能角度来看,序列化是一个重要问题,因为Web服务在SOAP消息中使用XML.
因此减少序列化 XmlIgnore
要在对象传递到Web方法或从Web方法传递对象时限制对象公开的字段,并减少通过线路发送的数据量,XmlIgnore应使用该属性,如下所示.
该XmlSerializer班将忽略该属性标注的任何领域.
请注意,XmlIgnore与从IFormatter接口派生的格式化程序不同,仅序列化公共成员.
// 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;
}
Run Code Online (Sandbox Code Playgroud)
在这里,作者提到了有关Inproving Webservices的提示,其中就是使用XmlIgnoreAttribute
我通过Apache CXF Framework开发了一个使用Java的Web服务.
请告诉我如何在Java技术中使用它或任何类似的属性?
使用JAX-WS(SOAP)或JAX-RS(RESTful)实现实现的Web服务使用JAXB(JSR-222)作为绑定层.使用JAXB时,您可以利用@XmlTransient注释从XML表示中排除字段/属性.
欲获得更多信息