[英]gSOAP C++: nillable attributes
how is it possible to set the xsi:nil="true" attribute on only single elements? 如何仅在单个元素上设置xsi:nil =“ true”属性? With the runtime-flag "SOAP_XML_NIL" I will set it globally, so it affects every attribute.
通过运行时标记“ SOAP_XML_NIL”,我将对其进行全局设置,因此它会影响每个属性。
Thank you 谢谢
To add xsi:nil="true"
automatically to the XML payload when a class/struct member is NULL, you will only need to annotate the member as required (with a 1
): 要在类/结构成员为NULL时将
xsi:nil="true"
自动添加到XML有效负载中,您只需要根据需要注释该成员(带有1
):
class ns__some_data
{
public:
int *some_member 1; // nillable pointer & element is marked as required
};
When setting ns__some_data::some_member = NULL
, the XML will have the xsi:nil
attribute, which is what I think you want: 设置
ns__some_data::some_member = NULL
,XML将具有xsi:nil
属性,这是我认为您想要的:
<ns:some-data>
<some-member xsd:nil="true"/>
</ns:some-data>
To make sure this works as expected, you will need to upgrade to the latest version of gSOAP (2.8.28 or later). 为确保此操作按预期进行,您将需要升级到最新版本的gSOAP(2.8.28或更高版本)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.