使用gSOAP与WebService - 第一部分 为VC++从WSDL读取信息
CurrencyConvertor - How use gSOAP and WebServices - Part 1 Get ready with VC++ 6 from WSDL file
IntroductionIn this article,I explain how to build a web service client from a wsdl file. I am releasing this project to help those who won't begin to use a web Service with gSOAP. I won't,however,be explaining about XML Serialization,Transient Types,Memory Management,etc. I split the article into two parts for easier learning,and better understanding. In Part One I will explain how to get the class from the wsdl file to be used in VC++ 6. In Part Two,I show you how to use the classes generated with gSOAP. To begin you will want:
After downloading the file,you have to build a C++ class (from the wsdl file). Go to gSoap dir and open bin sub-folder (something like this: D:/gsoap-win32-2.7/bin). Here you find two executable files:
Wsdl importer : Generates the file with C++ bindingsCopy the wdsl to this directory and run wsdl2h.exe like this: wsdl2h -o WSCurrencyConv.h CurrencyConvertor.wsdl In the shell you'll see some warning (ignore this) and at the end "To complete the process.compile with: soapcpp2 WSCurrencyConv.h". If all works fine you'll see a new file in the directory that will be WSCurrencyConv.h (or the name you write at the command line). N.B. You shouldn't have problems,but if you do,check the name and path you entered and try again. gSOAP compiler: generate the proxy and XML serialization routines in source-code formatRun soapcpp2.exe like this: soapcpp2 -ID:/gsoap-win32-2.7/Import WSCurrencyConv.h To run this executable you need to set the path for the gSOAP import (something like this: D:/gsoap-win32-2.7/import). This is similar to what I did before with -ID:/gsoap-win32-2.7/Import. The second param is the file .h you entered the first time with wsdl2h. If it works you'll see in the last line "Compilation successful". Now in the directory you'll see a few new files. N.B. You shouldn't have problems but if you do,check that the path for the import file exists. Otherwise you can copy all the files in the import directory to the bin directory and try again. The new files will be:
Using the VC++Now you have all you want to begin deploying your application with VC++. Include self-generated code into VC++ project:
The Project is ready to communicate with the WS. You have all the classes you need to begin. N.B You could get this warning (shown below) but don't worry and go ahead. This warning is derived from the self-generated class with gSOAP; gSOAP doesn't check the maximum characters. Points of InterestI read many books online. I find there are numerous mistakes,and that all the examples are unusable. These books may have all you want to know in order to pass a university test,but there is too much information to begin a project. Irritated,I did this project to let you to begin to write a WS client. History
About Dr.Luiji?(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |