Symbian Study Notes (21)-the tool wsdl2cpp was used to access WebService.

Source: Internet
Author: User

In the forum, someone asked me how to use wsdl2cpp to generate code. Only then did I know that Symbian provided an auxiliary tool to generate the WebService client code, it is much easier than the WebService client I used to refer to the addressbook example, which is similar to the use of gsoap.

First, go to forum.nokia.com.cn to search for the WSDL-to-C ++ _ for_s60. This is a tool for CARBICE vs. However, you can install it independently and use the command line to generate the required code. Download and install it.

Step 2: run its wsdl2cpp tool to get some source code, but it is a little bit inferior to gsoap and cannot directly provide a wsdl url. Therefore, it is best to download the WSDL to the local device, just give it a file name:

Wsdl2cpp -- callback-class pserviceconsumer -- include-Dir./work/INC -- source-Dir./work/src pservice. WSDL

In this way, the headers and source files generated under work/src and work/INC under the current directory will be obtained. The implementation principle is still implemented using the built-in Web Service API of Symbian. Get the code to the project.

Step 3: code is added in the project and the modification of MMP is the same as using these Apis directly. In short, this tool only helps us generate the source code framework, which is more convenient. However, there is an additional addition:

Library xmldatabinding. Lib
Userinclude/epoc32/include/libc
Userinclude/epoc32/include/xmldatabinding

In its directory, open the corresponding epoc32 directory. It includes lib and some header files.

In addition, you should install xmldatabinding. Sis on your mobile phone. From this point of view, it seems a little more troublesome than gsoap.

Step 4: Now it's easy to modify the code.

private:// DataCHelloWSThreeAppView* iAppView;CPServiceService * iService;CPServiceConsumer * iObserver;

Add iservice and iobserver to the header file. There are two steps in CPP: Initialize the connection and remote call:

// The initialization code csenxmlservicedescription * pservicedesc = csenxmlservicedescription: newlc (kserviceendpoint, endpoints (); pservicedesc-> setframeworkidl (endpoints); iobserver = cpserviceconsumer: newlc (); iservice = cpserviceservice: newlc (* iobserver, * pservicedesc); _ timeout (kstr, "init service. "); log (kstr); // Remote Call code here if (iobserver-> istatus = ksenconnectionstatusready) {rhelloworld ahello; rhelloworldresponse ahelloresp; trapd (error, ahelloresp = iservice-> helloworldl (ahello); If (error) {rdebug: printf ("error % d", error);} tbuf <64> Buf; Buf. copy (ahelloresp. ihelloworldresult); _ substring (kstr, "result is % s"); log_format (kstr, Buf ));}

This is fine. Of course, you need to delete these member variables during structure analysis.

To sum up, I actually use three methods to call web services, which are the simplest helloworld. In comparison, gsoap is more convenient.

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.