精通
英语
和
开源
,
擅长
开发
与
培训
,
胸怀四海
第一信赖
锐英源精品开源心得,转载请注明:“锐英源www.wisestudy.cn,孙老师作品,电话13803810136。”需要全文内容也请联系孙老师。
我以前写过文章,描述过直接写个.h文件来写gSOAP服务器,本文介绍了从wsdl文件来生成服务代码,虽然内容有些旧,但在过程上有参考意义。说它旧,因为还是用的VC6,如果在校学生看本文还合适,现在工作里普遍用了VS2010、VS2013、VS2015等等。
In this article, I explain how to build a web service client from a WSDL file. I am releasing this project to help those who wish to begin to use a web service with gSOAP. I won't, however, be explaining about XML Serialization, Transient Types, Memory Management, etc. 在本文中,我将解释如何从WSDL文件构建Web服务客户端。我正在发布这个项目,以帮助那些希望开始使用gSOAP开发Web服务的朋友。但是,我不会解释XML序列化,瞬态类型,内存管理等。
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 Visual C++ 6. In Part Two, I show you how to use the classes generated with gSOAP. 我将文章分为两部分,以便于学习和更好地理解。在第一部分中,我将解释如何从WSDL文件中获取要在Visual C ++ 6中使用的类。在第二部分中,我将向您展示如何使用gSOAP生成的类。
To begin, you will want: 首先,您需要:
Info: I used a free web service from WebserviceX.NET. If their server is busy and you get the the error "service unavailable," see if it's working here. After downloading the file, you have to build a C++ class from the WSDL file. Go to the gSoap directory and open the bin sub-folder, something like this: D:\gsoap-win32-2.7\bin. Here, you find two executable files: 信息:我使用了WebserviceX.NET提供的免费Web服务。如果他们的服务器很忙并且您收到错误“服务不可用”,请查看它是否在此处工作。下载文件后,您必须从WSDL文件构建C ++类。转到gSoap目录并打开bin子文件夹,如下所示:D:\ gsoap -win32-2.7 \ bin。在这里,您找到两个可执行文件:
Copy the WSDL to this directory and run wsdl2h.exe like this: 将WSDL复制到此目录并运行wsdl2h.exe,如下所示:
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). 在shell中,您将看到一些警告(忽略这一点),最后“要完成该过程,请使用:soapcpp2 WSCurrencyConv.h进行编译”。如果一切正常,您将在目录中看到一个新文件,该文件将是WSCurrencyConv.h(或您在命令行中写入的名称)。
N.B. You shouldn't have problems, but if you do, check the name and path you entered and try again. 注意:您不应该遇到问题,但如果这样做,请检查您输入的名称和路径,然后重试。
Run soapcpp2.exe like this: 像这样运行soapcpp2.exe:
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: 要运行此可执行文件,您需要设置gSOAP导入的路径,如下所示:D:\gsoap -win32-2.7 \ import。这与我之前的做法类似:
-ID:\gsoap-win32-2.7\Import
The second parameter 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. 第二个参数是您用wsdl2h时第一次输入的文件* .h。如果它有效,你会在最后一行“编译成功”中看到。现在在目录中,您将看到一些新文件。
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. 注意:您不应该遇到问题,但如果这样做,请检查导入文件的路径是否存在。否则,您可以将导入目录中的所有文件复制到bin目录,然后重试。
The new files will be: 新文件将是:
Now you have all you want to begin deploying your application with Visual C++.现在,您已经准备好使用Visual C ++开始部署应用程序了。