C and C++ XML Data Bindings {#mainpage}
===========================
[TOC]
Introduction {#intro}
============
This article presents a detailed overview of the gSOAP XML data bindings for C
and C++. The XML data bindings for C and C++ are extensively used with gSOAP
Web services to serialize C and C++ data in XML as part of the SOAP/XML Web
services payloads. Also REST XML with gSOAP relies on XML serialization of C
and C++ data via XML data bindings.
The major advantage of XML data bindings is that your application data is
always **type safe** in C and C++ by binding XML schema types to C/C++ types.
So integers in XML are bound to C integers, strings in XML are bound to C or
C++ strings, complex types in XML are bound to C structs or C++ classes, and so
on. The structured data you create and accept will fit the data model and is
**static type safe**. In other words, by leveraging strong typing in C/C++,
your XML data meets **XML schema validation requirements** and satisfies **XML
interoperability requirements**.
In fact, gSOAP data bindings are more powerful than simply representing C/C++
data in XML. The gSOAP tools implement true and tested **structure-preserving
serialization** of C/C++ data in XML, including the serialization of cyclic
graph structures with id-ref XML attributes. The gSOAP tools also generate
routines for deep copying and deep deletion of C/C++ data structures to
simplify memory management. In addition, C/C++ structures are deserialized
into managed memory, managed by the gSOAP `soap` context.
At the end of this article two examples are given to illustrate the application
of XML data bindings. The first simple example <i>`address.cpp`</i> shows how to use
wsdl2h to bind an XML schema to C++. The C++ application reads and writes an
XML file into and from a C++ "address book" data structure as a simple example.
The C++ data structure is an STL vector of address objects. The second example
<i>`graph.cpp`</i> shows how C++ data can be accurately serialized as a tree, digraph,
and cyclic graph in XML. The digraph and cyclic graph serialization rules
implement SOAP 1.1/1.2 multi-ref encoding with id-ref attributes to link
elements through IDREF XML references, creating a an XML graph with pointers to
XML nodes that preserves the structural integrity of the serialized C++ data.
These examples demonstrate XML data bindings only for relatively simple data
structures and types. The gSOAP tools support more than just these type of
structures to serialize in XML. There are practically no limits to the
serialization of C and C++ data types in XML.
Also the support for XML schema (XSD) components is unlimited. The wsdl2h tool
maps schemas to C and C++ using built-in intuitive mapping rules, while
allowing the mappings to be customized using a <i>`typemap.dat`</i> file with mapping
instructions for wsdl2h.
The information in this article is applicable to gSOAP 2.8.26 and greater that
support C++11 features. However, C++11 is not required. The material and the
examples in this article use plain C and C++, until the point where we
introduce C++11 smart pointers and scoped enumerations. While most of the
examples in this article are given in C++, the concepts also apply to C with
the exception of containers, smart pointers, classes and their methods. None
of these exceptions limit the use of the gSOAP tools for C in any way.
The data binding concepts described in this article were first envisioned in
1999 by Prof. Robert van Engelen at the Florida State University. An
implementation was created in 2000, named "stub/skeleton compiler". The first
articles on its successor version "gSOAP" appeared in 2002. The principle of
mapping XSD components to C/C++ types and vice versa is now widely adopted in
systems and programming languages, including Java web services and by C# WCF.
We continue to be committed to our goal to empower C/C++ developers with
powerful autocoding tools for XML. Our commitment started in the very early
days of SOAP by actively participating in
[SOAP interoperability testing](http://www.whitemesa.com/interop.htm),
participating in the development and testing of the
[W3C XML Schema Patterns for Databinding Interoperability](http://www.w3.org/2002/ws/databinding),
and continues by contributing to the development of
[OASIS open standards](https://www.oasis-open.org) in partnership with leading
IT companies in the world.
ð [Back to table of contents](#)
Notational Conventions {#conventions}
======================
The typographical conventions used by this document are:
* `Courier` denotes C and C++ source code.
* <i>`Courier`</i> denotes XML content, JSON content, file and path names, and URIs.
* <b>`Courier`</b> denotes HTTP content, text file content, and shell commands with command line options and arguments.
The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD",
"SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to
be interpreted as described in RFC-2119.
ð [Back to table of contents](#)
Mapping WSDL and XML schemas to C/C++ {#tocpp}
=====================================
To convert WSDL and XML schemas (XSD files) to code, we use the wsdl2h command
on the command line (or command prompt), after opening a terminal. The wsdl2h
command generates the data binding interface code that is saved to a special
Web services and data bindings interface header file with extension <i>`.h`</i>
that contains the WSDL service declarations and the data binding interface
declarations in a familiar C/C++ format:
wsdl2h [options] -o file.h ... XSD and WSDL files ...
This command converts WSDL and XSD files to C++ (or pure C with
<b>`wsdl2h -c`</b>) and saves the data binding interface to a interface header
file <i>`file.h`</i> that uses familiar C/C++ syntax extended with `//gsoap`
[directives](#directives) and annotations. Notational conventions are used in
the data binding interface to declare serializable C/C++ types and functions
for Web service operations.
The WSDL 1.1/2.0, SOAP 1.1/1.2, and XSD 1.0/1.1 standards are supported by the
gSOAP tools. In addition, the most popular WS specifications are also
supported, including WS-Addressing, WS-ReliableMessaging, WS-Discovery,
WS-Security, WS-Policy, WS-SecurityPolicy, and WS-SecureConversation.
This article focusses mainly on XML data bindings. XML data bindings for C/C++
bind XML schema types to C/C++ types. So integers in XML are bound to C
integers, strings in XML are bound to C or C++ strings, complex types in XML
are bound to C structs or C++ classes, and so on.
A data binding is dual, meaning supporting a two way direction for development.
Either you start with WSDLs and/or XML schemas that are mapped to equivalent
C/C++ types, or you start with C/C++ types that are mapped to XSD types.
Either way, the end result is that you can serialize C/C++ types in XML such
that your XML is an instance of XML schema(s) and is validated against these
schema(s).
This covers all of the following standard XSD components with their optional
attributes and properties:
XSD component | attributes and properties
-------------- | -------------------------
schema | targetNamespace, version, elementFormDefault, attributeFormDefault, defaultAttributes
attribute | name, ref, type, use, default, fixed, form, targetNamespace, wsdl:arrayType
element | name, ref, type, default, fixed, form, nillable, abstract, substitutionGroup, minOccurs, maxOccurs, targetNamespace
simpleType | name
complexType | name, abstract, mixed, defaultAttributesApply
all | *n/a*
choice | minOccurs, maxOccurs
sequence | minOccurs, maxOccurs
group | name, ref, minOccurs, maxOccurs
attributeGroup | name, ref
没有合适的资源?快使用搜索试试~ 我知道了~
gsoap 2.8.82
共2000个文件
xml:2273个
html:1700个
png:1057个
3星 · 超过75%的资源 需积分: 10 23 下载量 164 浏览量
2019-03-20
17:37:44
上传
评论
收藏 31.01MB ZIP 举报
温馨提示
gSOAP 编译工具提供了一个SOAP关于C/C++ 语言的实现,从而让C/C++语言开发Web Services服务端或客户端程序的工作变得轻松了很多。甚至,即使你对Web Services不甚了解都没有关系,有了gSOAP这样的工具,你也能开发基于SOAP方式实现的Web Services客户端。 gSOAP工具根据WSDL文档,自动生成C/C++语言的客户端/服务端框架代码。这其中有两个工具很重要,wsdl2h和soapcpp2。wsdl2h工具根据WSDL文成C/C++头文件,而soapcpp2工具则是根据该头文件生成C/C++的框架源码。 gSOAP工具可以在Windows、Linux和Macosx操作系统下运行,gSOAP工具包中自带有Windo ws和Macosx操作系统的wsdl2h和soapcpp2可执行文件,而Linux操作系统的,得自己编译。 通过实验证实,用Windows和Linux工具生成的框架代码,是一样样的,没有区别。 如何使用gSOAP,在gSOAP官网,或者在工具包gsoap\doc\soapdoc2.pdf文档中都有很详细的说明,大家可以参考。
资源推荐
资源详情
资源评论
收起资源包目录
gsoap 2.8.82 (2000个子文件)
symbol2.c 959KB
symbol2.c 959KB
stdsoap2.c 617KB
wsseapi.c 292KB
soapcpp2_yacc.tab.c 237KB
soapcpp2_yacc.tab.c 237KB
cacerts.c 211KB
cacerts.c 211KB
wsrmapi.c 192KB
dom.c 170KB
wsse2api.c 153KB
lex.soapcpp2_lex.c 104KB
lex.yy.c 104KB
wsaapi.c 61KB
wsddapi.c 59KB
webserver.c 55KB
mecevp.c 53KB
httpda.c 52KB
sessions.c 49KB
mod_gsoap.c 49KB
mod_gsoap.c 48KB
optC.c 44KB
wsseapi-lite.c 31KB
wssedemo.c 30KB
wsrmdemo.c 29KB
curlapi.c 29KB
json.c 29KB
router.c 28KB
wstapi.c 28KB
smdevp.c 27KB
wstdemo.c 26KB
mtom-stream-test.c 20KB
mq.c 16KB
soapcpp2.c 15KB
soapcpp2.c 15KB
options.c 14KB
xml-rpc.c 14KB
tandemnw.c 13KB
mtom-test.c 13KB
rss.c 13KB
httppost.c 12KB
httpget.c 9KB
httpmd5.c 9KB
tandem.c 9KB
ssl_setup.c 9KB
sslserver.c 9KB
sslclient.c 9KB
wsademo.c 8KB
wsselite.c 8KB
struct_timeval.c 7KB
struct_tm.c 7KB
httppipe.c 7KB
asyncrest2.c 7KB
init2.c 7KB
init2.c 7KB
httpposttest.c 7KB
httpposttest.c 7KB
logging.c 7KB
udpserver.c 7KB
httpform.c 6KB
struct_tm_date.c 6KB
long_time.c 6KB
duration.c 6KB
int128.c 6KB
httpdatest.c 6KB
long_double.c 6KB
asyncrest3.c 6KB
handler.c 6KB
json-currentTimeServer.c 5KB
asyncsoap2.c 5KB
float128.c 5KB
event.c 5KB
asyncrest.c 5KB
asyncsoap3.c 5KB
error2.c 4KB
error2.c 4KB
threads.c 4KB
curlrest.c 4KB
md5evp.c 4KB
mashupserver.c 4KB
udpclient.c 4KB
xmas.c 4KB
plugin.c 4KB
asyncsoap.c 4KB
server.c 4KB
curlclient.c 4KB
calcserver.c 4KB
calcrest.c 3KB
chaining.c 3KB
httpgettest.c 3KB
httpgettest.c 3KB
curl-json-currentTime.c 3KB
client.c 3KB
calcclient.c 3KB
ckdb.c 3KB
xml-rpc-weblogs.c 3KB
json-GitHub.c 3KB
thread_setup.c 3KB
httpmd5test.c 3KB
json-currentTime.c 3KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
- chen2707210102019-06-04感觉没有那么实用
指尖音符
- 粉丝: 12
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- BLOCK_TYPE_HEARTBEAT_D70A3465D4EE4E9_046141_dump_1st.dmp
- 项目方法测试调用接口工具
- studyupdate
- 基于西瓜数据集的决策树实现.zip
- 60套HTML网站源码-响应式-涵盖(简历&作品展示&商业&科技&培训&商城&课设等)-适配移动设备-解压即用.zip
- 贪心算法要点和难点实例代码解析
- 65套HTML网站源码-响应式-涵盖(简历&作品展示&商业&科技&培训&商城&课设等)-适配移动设备-解压即用.zip
- 多因素决策树的Python实现.zip
- 使用Python在莺尾花数据集上实现了决策树算法,文件里有数据集.zip
- python实现决策树.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功