简体   繁体   English

Web服务响应转换问题

[英]Web services response conversion issue

I am using 'n' number of web services in my systems. 我在系统中使用n个Web服务。 I am very well taking care. 我很好照顾。 But, in recent days I am just seeing a strange behaviour while handling response of one my external systems. 但是,最近几天,在处理我的外部系统的响应时,我只是看到一种奇怪的行为。

Here is my problem, 这是我的问题

When I request one of my downstream system for getting data, i am getting response with one very big xml. 当我请求我的下游系统之一获取数据时,我得到了一个非常大的xml的响应。 During parsing the response in system, the complete JAVA thread itself got struck more than configured time. 在系统中解析响应期间,完整的JAVA线程本身受到的攻击超过了配置的时间。 So for temporary fix, we request downstream system to limit the response. 因此,对于临时修复,我们要求下游系统限制响应。

But, how this is happening? 但是,这是怎么回事? Irrespective of how big the data, the unmarshlling process should complete right. 不管数据量有多大,拆封过程都应正确完成。

So may i know what was the root cause of this issue ? 那么,我是否可以知道此问题的根本原因是什么?

If you are unmarshalling then the whole XML will be converted to one object graph containing all the objects specified in the XML. 如果您要解组,则整个XML将转换为一个包含XML中指定的所有对象的对象图。 So the bigger the XML the bigger the resulting object graph. 因此,XML越大,生成的对象图就越大。 Of course this takes more memory, perhaps more than your application has to its disposition, which could lead to an OutOfMemoryException. 当然,这会占用更多的内存,可能比您的应用程序需要的内存更多,这可能导致OutOfMemoryException。 If the XML received contains some kind of a list of items you can consider handling it item by item. 如果收到的XML包含某种项目列表,则可以考虑逐项处理它。 You will read in one item at a time and then process it and dispose of it. 您将一次读入一项,然后对其进行处理和处置。 You will then need only the amount of memory to fit one item's object graph in memory. 然后,您只需要内存量就可以在内存中容纳一项的对象图。 But to do this you would have to rewrite your processing code to use a library like SAX . 但是要做到这一点,您将不得不重写处理代码以使用像SAX这样的库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM