Search code examples
c++web-servicesqtgsoap

Why sending binary data over gSOAP is too much slow?


I am trying to send an image from a client application to server using gSOAP web services and C++. To this aim, I am using Qt and my client and server applications could operate on both Windows and Linux. The surprising part is that for a 1MB jpg image, it takes about 6 seconds to send the image from client to server running on the same machine on both Linux and Windows platforms. Is there something wrong with my application or any other web service technology will take the same time?

P.S. To send data, I am using the type unsigned char *.

Edit 1: How can I send binary data over gSOAP using base64 data type. As I've read the documentation, no data type is available in the .stub files.


Solution

  • The XSD base64Binary type is an XML schema-native raw binary type. Performance should be very good with -DDEBUG disabled (because message logging is slow!).

    The gSOAP tools generate efficient XML serializers that push and pull base64 over the wire while converting from/to raw data directly.

    Here are some numbers on a typical system, assuming low network overhead:

    • Echo 1K base64 100 times (i.e. 200 messages with 1K base64):
      Elapsed real time = 140 (ms) CPU time = 120 user = 40 system = 80
    • Echo 100K base64 100 times (i.e. 200 messages with 100K base64):
      Elapsed real time = 820 (ms) CPU time = 450 user = 280 system = 170
    • Echo 1MB base64 100 times (i.e. 200 messages with 1MB base64):
      Elapsed real time = 5650 (ms) CPU time = 3730 user = 2740 system = 990

    Network bandwidth may be a factor in your performance.

    PS. You may want to try SOAP_IO_CHUNK for chunked transfers. A more aggressive approach is to change SOAP_BUFLEN (normally 64K) to optimize socket buffer size (and recompile all sources that include stdsoap2.h to make sure the new buffer size is used).