Data transfer from server interface functions under gsoap

Source: Internet
Author: User
Tags soap client

I. Introduction

    Gsoap is an opensource web service development tool, including server/Client Communication and WSDL
    The automatic generation function can generate server and client code based on the WSDL file. The generated code is compact, concise, and does not depend on other XML parsing libraries, which is easy to transplant and greatly reduces
    Workload of WebService programmers. It provides a unique soap/XML binding method to C/C ++ to simplify soap/XML in C or C ++.
    Development of web services and clients. The gsoap tool includes a WSDL generator used to generate a Web Service Description for your web service. WSDL importer
    The tool completely automates the development of soap client applications.

    Gsoap greatly simplifies the Web Service Development Process Using C/C ++. It is a better choice for C/C ++ developers to develop Web Services. For the installation and development documentation of gsoap, see [1], [2], and [3]. Below we will focus on the data transfer of server interface functions under gsoap.

Ii. Single outgoing Parameters

    The Return Value of the gsoap interface function can only be int, which is the result of a soap call. Generally, soap. error is used to determine the soap connection. The last parameter of the interface function is the outgoing parameter and must be of the reference or pointer type (Note: The input parameter is of the reference type ). As follows:

    Int NS _ add (struct soap * add_soap, int num1, int num2, int * sum );

3. Multiple outgoing Parameters

    If multiple parameters need to be transferred out, you need to define a structure to encapsulate the return items, and then use this struct as a single parameter. As follows:

    Struct type_return {

      Int ID;
      Char * Name;
      Int age;

    }

    Int NS _ getinfo (struct soap * soap, int ID, struct type_result * RET );

Iv. binary data transfer

    None
    About axis
    C ++ or gsoap does not support complex data types very well, plus gsoap. the H file cannot contain (# include. h file, may not take effect, so you need
    To use the void data type, do not specify the data type, and return the data before processing. However, gsoap cannot perform serialize operations on the void data type unless
    Union or struct allocates real-time type information. Therefore, when transmitting binary data, you need to use the XSD _ base64binary structure type for operations. As follows:
    Struct XSD _ base64binary {

      Unsigned char * _ PTR;
      Int _ size;

    };

    When using the above structure, you may need to use soap_malloc () for memory allocation and allocate the _ size value.

    Int NS _ demofunction (struct soap * soap,..., struct XSD _ base64binary * RET)
    {

      ...
      Ret->__ PTR = (unsigned char *) soap (soap, size);/* size is the memory size */
      Ret-> __size = size;
      Memset (ret-> __ptr, 0, size );
      Memcpy (ret->__ PTR, src_ptr, size);/* src_ptr is the source data block pointer */
      ...
      Return soap_ OK;

    }

V. file data transfer

    Soap
    The protocol supports the attachment (Attachment), and gsoap supports MIME/dime attachments. We can use this feature to transfer the entire file or a large amount of data. Gsoap attachment operation
    Returns very similar to binary data in (4). It also uses struct.
    XSD _ base64binary type. At this time, no duplicates are repeated. For more information, see #13 mime attachments in [2.

Vi. References

1. Official Website
2. gsoap User Guide
3. Construct a Web Service C/C ++ Client
4. Use C to implement WebService

To
Http://hi.baidu.com/songfeng163/blog/item/89ac27f7a3578f20720eecf3.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.