Which is better? High number of web service calls (SOAP messages) or high amount of data in single Soap Message?

不打扰是莪最后的温柔 提交于 2020-08-06 22:31:51

问题



I am designing a mobile application which gets server data through SOAP messages.

I wanted to know what is the best practice:

  • More number of web service calls fetching less data in each SOAP message call.
    OR
  • I get all data in a single web service call but then the length of SOAP message would be large.

    Wouldn't the high amount of data in a single soap message create data connectivity issues for mobile subscriber.

    In my application for a particular year I have to get names of all car manufacturers and model names for all cars by each manufacturer. I have two plans:
  • As the user selects a year I send a web service which will get all the data.
  • As the user selects a year I get the names of manufacturers and then when user selects a manufacturer i get all the models for that manufacturer.
    please help by telling me which approach should I take.

*PS:*user can have many vehicles and if I use second approach then web services will be called for every vehicle.


回答1:


What sort of size responses are we talking about - min / max / typical?

There's no simple answer to this question as it depends on what triggers the web-service request e.g. is it in response to a user action, timed etc.

Latency is one of the killers over mobile networks (more important than low bandwidth) so in theory you should aim for a minimum number of requests.

but...

There's no point in making large requests if you don't need the data.

My guess is you're going to have to test with different response sizes to find the sweet spot.

Also don't forget to allow gzip/deflate in the request and compress the response from the server.

If possible I'd also go for a RESTful approach and ensure the GET responses are cacheable




回答2:


Couple of points

  1. As pointed out in the comment Use JSON instead of SOAP where ever possible, SOAP is very heavy weight and is not being recommended these days.( look at all the endpoints being exposed by Google and others - most of them use JSON )

  2. If the xml size is becoming too large ( beyond few kilobytes) it is better to make multiple calls rather than loading a large object in memory.




回答3:


On a mobile connection, I'd opt for larger responses because of the network latency. It's better to fetch a bunch of things in one go than to fetch each item in a new roundtrip. This will keep your app fast.

Even larger responses can be efficiently handled without needing to store those in memory if you use a library that can "stream" the response.



来源:https://stackoverflow.com/questions/8308992/which-is-better-high-number-of-web-service-calls-soap-messages-or-high-amount

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!