Soap Study Notes (1)

Source: Internet
Author: User
Tags soap wsdl

Source: http://blog.sina.com.cn/s/blog_4c31626a010008s2.html

      Recently, I started to learn the source code of gsoap. The source code of gsoap_win32_2.7.9f is downloaded from the Internet. Gsoap consists of two functional modules, corresponding to the wsdl2h and soapcpp2 commands respectively. The source code of wsdl2h is in the WSDL directory, while the source code of soapcpp2 is in the src directory. Wsdl2h is a module used to parse the WSDL file. It converts the input WSDL file into an H file. Specifically, it is an intermediate file, which records the useful information obtained by WSDL parsing in a recognizable format of soapcpp2. Soapcpp2 analyzes the H file and generates the server and client code of the Web application. Application code can be in two forms: pure C code and C ++ code.        Because of the rebuildproject, wsdl2h.exeand soapcpp2.exe without gsoapare used. Creating a gsoap project under vc6 is a code porting process. Gsoap source code generation uses the lexical analysis tool flex and syntax analysis tool bison under UNIX. If encryption is required for Web Services, OpenSSL and zlib compression libraries are also required. Use flex.exeand bison.exe in cygwinto generate the required code. Code
PortingThe process is relatively simple and will not be repeated.       After wsdl2h.exeand soapcpp2.exe are generated, you can use gsoap to build a simple "C-S" Web application.      From the official website of the soaptest tool, the WSDL file of the simplest calculator service is: calculator. WSDL. Use wsdl2h to parse the file:        Wsdl2h-c-o Calculator. h calculator. WSDL        Generate H file calculator. h. The-C parameter indicates that the application code of pure C is generated. Use:        Soapcpp2 calculator. h        Generate the final server and client soap framework code. The soap framework code can be compiled to generate static libraries of the server and client, or compiled directly into the application. I use the latter.        For the application of the soap framework code, because the soap framework code has implemented and encapsulated all the functions below the business layer, the application code only needs to focus on the implementation of the business layer. On the client side, you need to write code: Call the service request interface generated by gsoap, input parameters, and retrieve the returned service response results. On the server side, you need to write the functional code of each specific business. The interface prototype of these businesses has been generated in the Framework Code, as long as the function entity is implemented.        In the samples directory of gsoap, there is a calc example which is very similar to the calculator. WSDL service function used above. It can be "tainism" directly, and it will be OK if it is modified.      Because only tests are performed on the local machine, the connection address of the client directly uses "127.0.0.1 ". Compile and generate the server program calcserver.exeand calcclient.exe.      Start the Web service first:        Calcserver 80        80 indicates the http port. Then start the client and request the result of 3 + 5:        Calcclient A 3 5        A is the add service request, and 3 and 5 are the input parameters of the add service. Return after execution:        Result = 8        Since then, we have basically completed the understanding, application, and simple verification of gsoap. Due to project requirements, you may need to thoroughly understand the WSDL parsing function of the gsoap front-end. You will have time to thoroughly analyze the gsoap source code. ^_^

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.