使用gSOAP与WebService - 第一部分 为VC++从WSDL读取信息

2023-10-26

CurrencyConvertor - How use gSOAP and WebServices - Part 1 Get ready with VC++ 6 from WSDL file

Screenshot - CurrencyConvertor-Part11.jpg

Introduction

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 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:

  • gSoap Toolkit - Download gSoap Toolkit for windows and unzip it in a directory. You can download it form various sites. I used the site SourceForge and I downloaded the last release: gsoap_win32_2.7.8c.zip
  • WSDL - Download the "WSDL Schema Location" and save it with a wsdl extension. I used this WSDL, you can use another like CryptoService, DotGetLocator etc.)

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:

  • wsdl2h.exe: Allows you do bindings in a C/C++ header file(.h) from the wsdl file you downloaded before. (intermediate header)
  • soapcpp2.exe: Allows you to build a class with C++ formatting from the intermediate header.

Wsdl importer : Generates the file with C++ bindings

Copy the wdsl to this directory and run wsdl2h.exe like this:

wsdl2h -o WSCurrencyConv.h CurrencyConvertor.wsdl 

Sample use of wsdl2h

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 format

Run soapcpp2.exe like this:

soapcpp2 -ID:/gsoap-win32-2.7/Import WSCurrencyConv.h

Sample use of soapcpp2

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:

  • CurrencyConvertorSoap.ConversionRate.req.xml
  • CurrencyConvertorSoap.ConversionRate.res.xml
  • CurrencyConvertorSoap.nsmap
  • soapC.cpp
  • soapClient.cpp
  • soapClientLib.cpp
  • soapCurrencyConvertorSoapObject.h
  • soapCurrencyConvertorSoapProxy.h
  • soapH.h
  • soapServer.cpp
  • soapServerLib.cpp
  • soapStub.h

Using the VC++

Now you have all you want to begin deploying your application with VC++.

Include self-generated code into VC++ project:

  1. You need to include in your app the files below:
    • soapC.cpp
    • soapH.h
    • soapClient.cpp
    • soapStub.h
    • CurrencyConvertorSoap.nsmap
    • soapCurrencyConvertorSoapProxy.h
    • stdsoap2.h (This file is in the D:/gsoap-win32-2.7/import is the same for all the SW)
    • stdsoap2.cpp (This file is in the D:/gsoap-win32-2.7/import is the same for all the SW)
  2. Set the no precompiler header for the cpp files before.
    • Go to Project Settings (Alt-F7)
    • Change the Settings for: All configurations
    • Select the cpp file before adding to the project.
    • Go to the C++ tab, select the category "Precompiled headers" and select the radio button "Not using precompiled headers".

    VC++ settings

  3. Set the Namespace select the file stdafx.cpp and include the file CurrencyConvertorSoap.nsmap with this line
    • #include "CurrencyConvertorSoap.nsmap"
  4. Link the Ws2_32.lib to the project for use the Windows Sockets 2 API.
    • Go to Project Settings (Alt-F7)
    • Change the Settings for: All configurations
    • Go to tab Link, category General, add Ws2_32.lib to Objcet/Library modules

    VC++ settings

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.

Warning

Points of Interest

I 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

  • 12/07/2006: First release
<script src="/script/togglePre.js" type="text/javascript"></script>

About Dr.Luiji


Bertoneri Luigi, alias Dr.Luiji
Bachelor of Science in Computer science, year 2000 - University of Pisa (Italy).
I currently live in Italy.
Music I listen to: Slipknot, Type O Negative, Tool, Mushroomhead, Dry Kill Logic, System of a Down, White Zombie, RA, Slayer.

Click here to view Dr.Luiji's online profile.

 
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用gSOAP与WebService - 第一部分 为VC++从WSDL读取信息 的相关文章

随机推荐

  • 2023linux面试问答_Linux基础

    1 什么是Linux Linux是一套免费使用和自由传播的类Unix操作系统 是一个基于POSIX和Unix 的多用户 多任务 支持多线程和多CPU的操作系统 它能运行主要的Unix工 具软件 应用程序和网络协议 它支持32位和64位硬件
  • 深入随机数Random

    以下内容来自 http www cnblogs com rupeng p 3723018 html 今天再园子上看到了杨老师的一片blog 受益了 原来随机数还有这么多道道 要走的路还远啊 以下为个人收录 几乎所有编程语言中都提供了 生成一
  • windows2008文件服务器端口,windows server 2008 文件服务器不定期出现大量CLOSE_WAIT状态的连接,必须重启服务器,客户端才能访问共享。...

    故障现象如题 用netstat ano p tcp 可以看到大量的连接 都处于close wait状态 然后客户端访问共享就很卡 EXCEL也卡死 服务器重启恢复正常 但是过一段时间又出现这个问题 不知道有谁知道这个问题可能出在哪里 服务器
  • apt-cache - 搜索软件包

    Apt cache是一个命令行工具 可以从本地 APT 文件中查询和显示有关包的可用信息 包信息包括包名称 描述 版本 依赖项 repo 和维护者 存储来自 Debian 镜像的副本的本地 apt 文件位于 var lib apt list
  • day03-switch&循环语句

    1 流程控制语句 应用 在一个程序执行的过程中 各条语句的执行顺序对程序的结果是有直接影响的 所以 我们必须清楚每条语句的执行流程 而且 很多时候要通过控制语句的执行顺序来实现我们想要的功能 1 1 流程控制语句分类 顺序结构 分支结构 i
  • 计算机网络第五章——传输层(下)

    安得广厦千万间 大庇天下寒士俱欢颜 文章目录 按序的不丢失的 这个校验也是二进制求反码来判断有没有发送错误 TCP传输的时候就是以一个字节为单位 所以就会把一个字节编一个序号 对于一个文件第一个需要是多少是可以随机的 发送的时候是以报文段为
  • 4元数(转)

    这是国内找不到的超好文章 为什么大陆的4元数文章很垃圾呢 翻译中 奉献给大家 70秒即懂 能使用 用四元数 4元数 阔特尼恩 Quaternion旋转 C 中田 亨 独立行政法人 产业技术综合研究所 数字人类研究中心 研究员 博士 工学 2
  • wireshark抓包图解 TCP三次握手/四次挥手详解

    一 TCP IP协议族 TCP IP是一个协议族 通常分不同层次进行开发 每个层次负责不同的通信功能 包含以下四个层次 1 链路层 也称作数据链路层或者网络接口层 通常包括操作系统中的设备驱动程序和计算机中对应的网络接口卡 它们一起处理与电
  • 医疗大数据安全技术实践

    随着医疗大数据的不断积累 其安全性问题也逐渐受到广泛的关注 保护医疗大数据的安全和隐私至关重要 不仅需要制定相应的政策措施 更需要实际的技术实践 下面我将重点介绍医疗大数据安全技术实践的相关措施 1 数据加密技术 数据加密技术是医疗大数据安
  • 源码分享-go语言实现的snow3g加密算法

    源码路径 free5gc nas security snow3g snow3g go package snow3g var sr byte 0x63 0x7c 0x77 0x7b 0xf2 0x6b 0x6f 0xc5 0x30 0x01
  • 利用Python爬虫爬取淘宝商品做数据挖掘分析实战篇,超详细教程

    如需完整代码 加 LiteMango 付费 项目内容 本案例选择 gt gt 商品类目 沙发 数量 共100页 4400个商品 筛选条件 天猫 销量从高到低 价格500元以上 以下是分析 源码点击文末链接 项目目的 1 对商品标题进行文本分
  • Python爬虫要学多久

    Python爬虫要学三个月到半年 自学的话 根据每个人的情况来说 学习周期是不同的 如果没有任何基础 零基础小白进行Python学习的话 需要先进行简单的Python基础知识学习 就需要三个月左右的时间 再进行爬虫知识的学习 少则半年左右
  • 常用网址合集

    常用网址合集 一 壁纸网站 a AweSome Wallpapers 二 音乐网站 a 音乐下载器 三 电子书下载网站 a PDF之家 四 摸鱼网站 a Fakeupdate 很早之前就想收集一些比较常用的网址 最开始是直接放浏览器里面 但
  • 北大学生控诉字节跳动backup制度,怎么破解职场pua?

    5月13日下午 一名北大学生在校内论坛未名BBS上写下4000多字长文 陈述自己在字节跳动实习的经历 该同学表示 2021年1月份在字节跳动办理实习生入职 四月中旬实习期已满 且因毕业事宜繁忙向leader表达了近期需要离职的诉求 但竟遭遇
  • unity3d课后练习(四)

    文章目录 1 基本操作演练 建议做 2 编程实践 1 基本操作演练 建议做 下载 Fantasy Skybox FREE 构建自己的游戏场景 在 Asset Store 中搜索 Fantasy Skybox FREE 下载完成后 按照介绍导
  • better-scroll的学习和使用

    better scroll的学习和初始化 介绍 在日常的移动端开发中 列表滚动条的处理是非常常见的需求 横竖的滚动条使用better scroll都可以帮助我们在开发中实现 什么是better scroll better scroll是一个
  • Lattice Planner从入门到放弃

    Lattice Planner相关背景和更正式的公式推导可以直接参考其原始论文 Optimal Trajectory Generation for Dynamic Street Scenarios in a Fren t Frame ICR
  • protobuf快速上手

    protobuf快速上手 一 序列化与反序列化 序列化与反序列化的场景 常用的工具 二 protobuf工作原理 三 快速上手 protobuf中的数据类型 proto文件格式 编译选项 快速上手 四 通讯录demo 编写proto文件 编
  • 多DBWR进程与IO slave

    DBWn DBWn定期写脏数据到磁盘 频繁的磁盘I O会影响性能 所以每当数据库内存中产生脏数据时 是不一定也不应该产生写数据到磁盘的操作的 DBWn会尽量少的写入磁盘 虽然一个数据库DBW0进程适用于所有系统 为了提高数据库写的能力可以配
  • 使用gSOAP与WebService - 第一部分 为VC++从WSDL读取信息

    CurrencyConvertor How use gSOAP and WebServices Part 1 Get ready with VC 6 from WSDL file Download Demo 42 1 KB Download