用GSOAP解析肥皂味精
Parse soap msg with gSOAP
我有以下示例xml消息:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>
<to>...</to>
<from>...</from>
<id>..</id>
<relatesTo>...</relatesTo>
<action>...</action>
<version>...</version>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<customComplexElement>
<a>a_v</a>
<b>b_v</b>
<c>c_v</c>
<d>d_v</d>
<e>e_v</e>
<f>f_v</f>
</customComplexElement>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
我使用一种在线工具中生成了XSD文件:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified">
<import namespace="http://schemas.xmlsoap.org/soap/envelope/" schemaLocation="http://schemas.xmlsoap.org/soap/envelope/"></import>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="id" type="xs:string"/>
<xs:element name="relatesTo" type="xs:string"/>
<xs:element name="action" type="xs:string"/>
<xs:element name="version" type="xs:string"/>
<xs:element name="customComplexElement">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="a"/>
<xs:element type="xs:string" name="b"/>
<xs:element type="xs:string" name="c"/>
<xs:element type="xs:string" name="d"/>
<xs:element type="xs:string" name="e"/>
<xs:element type="xs:string" name="f"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
然后,我使用wsdl2h.exe生成适当的标头文件,然后用SOAPCPP2.EXE编译器编译。然后,我尝试使用功能soap_read_customcomplexelement()读取XML文件,而我所得到的只是soap_tag_mismatch。如果我摆脱了所有肥皂的东西,这种方法似乎可以工作,但是我想知道GSOAP中是否有一些功能来解析肥皂信封,标头和身体?
我遇到了同样的问题。但是我只是修复了它。因此,就我而言,我使用此代码。
struct soap *soap = soap_new1(SOAP_C_UTFSTRING | SOAP_XML_IGNORENS | SOAP_XML_TREE);
密钥参数为 soap_xml_ignorens 。此参数忽略名称空间。
SOAP_XML_IGNORENS in: ignores the use of XML namespaces in input
这个问题的根源是您不会在身体内容中声明名称空间。这就是为什么GSOAP不知道如何转换此XML。
这不会转换,因为GSOAP不知道什么是NS4:
<ns4:ParseKeywords><ns4:Keyword>Hello</ns4:Keyword></ns4:ParseKeywords>
,但是如果我声明名称空间,它将被转换
<ns4:ParseKeywords xmlns:ns4="com.idurdyev.idcommerce:ParseKeywords:1.0"><ns4:Keyword>Hello</ns4:Keyword></ns4:ParseKeywords>
相关文章:
- 使用GSoap实现ONVIF
- 使用 mod_gsoap 部署服务时,如何在 Gsoap 中更改 soap 上下文的模式?
- gSoap在从.wsdl创建.h期间出现错误
- 如何从客户端在 gsoap C++ 的标头中传递非 xml 数据?
- 在使用 gSoap 链接多个 SOAP 服务时启用保持活动状态
- 正在填充gsoap 2.8.59中的结构
- 使用c++的gSOAP中的stdsoap2.cpp中存在编译错误
- 使用 CMake (make) 和 GCC 构建和编译 gSOAP 项目
- 为没有 WSDL 的 Gsoap 创建一个标头
- 编译 gsoap 输出文件 (onvif) 时出现问题
- gSOAP - 未设置 SOAP 操作标头
- 有没有办法用c ++ Gsoap客户端调用python soap spyne服务器?
- GSOAP SOAPCPP2 #IMPORT:无法打开文件“ SOAP12.H”进行阅读
- 如何使用GSOAP初始化服务器上下文以启用简单身份验证(仅服务器身份验证)
- 在 soap_ssl_server_context(..) 中使用继承时 gsoap 中的分段错误
- 如何(优雅地)终止 gSOAP 服务器
- 在链接链接静态(GSOAP)库的共享库时,为什么会得到一个未定义的符号
- 具有GSOAP的序列化对象,以验证Web服务输出
- 如何在肥皂响应中添加标签
- 用GSOAP解析肥皂味精