What's better? A large number of web service calls (SOAP messages) or a large amount of data in a single Soap message?


I am developing a mobile application that receives server data through SOAP messages. I wanted to know what is best:

  • More web service calls that receive less data in every SOAP message call.
    OR
  • I get all the data in one web service call, but then the length of the SOAP message will be long.

    Will a large amount of data in one soapy message create problems with connecting to the network for mobile subscribers.

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

* PS: * a user can have many vehicles, and if I use the second approach, then web services will be called for each car.

+6
source share
3 answers

What size answers are we talking about - min / max / typical?

There is no simple answer to this question, because it depends on what causes the web service request, for example. this is in response to user action, time, etc.

Latency is one of the killers on mobile networks (which is more important than low bandwidth), so theoretically you should aim for a minimum number of requests.

but...

It makes no sense to make large queries if you do not need data.

I guess you will have to test with different sizes of answers to find a sweet spot.

Also, do not forget to allow gzip / deflate in the request and compress the response from the server.

If possible, I would also go for a RESTful approach and provide caching of GET responses

+1
source

Few points

  • As stated in the comment. Use JSON instead of SOAP, where possible, SOAP is very heavy and is currently not recommended. (look at all the endpoints that are displayed by Google and other users - most of them use JSON)

  • If the xml size becomes too large (in a few kilobytes), it is better to make several calls, rather than loading a large object into memory.

+2
source

In a mobile connection, I would choose larger answers due to network latency. It’s better to take a bunch of things at a time than pick up each item in a new circuit. This will speed up your application.

Even larger responses can be efficiently processed without having to store them in memory if you use a library that can "pass" the response.

+1
source

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