Namespace prefix attached in xsi:type value even for SOAP_XML_DEFAULTNS
Development toolkit for Web Services and XML data bindings for C & C++
Brought to you by:
engelen
In version - 2.8.17
We are using Amazon.xsd for testing complex attribute with inheritance. And earlier we used to receive
<Grantee xsi:type="CanonicalUser"> <ID>sample</ID> <DisplayName>sample</DisplayName> </Grantee>
But after upgrading to version 2.8.108 -
In version - 2.8.108, additional namespace prefix("s3:") is attached to "CanonicalUser"
<Grantee xsi:type="s3:CanonicalUser"> <ID>sample</ID> <DisplayName>sample</DisplayName> </Grantee>
The reason for this is the code which was removed from stdsoap2.cpp. That was present in 2.8.17 version before line - "if (soap_attribute(soap, "xsi:type", type))"
ifndef WITH_LEAN
if (soap->mode & SOAP_XML_DEFAULTNS) { s = strchr(type, ':'); if (s) s++; else s = type; }
Expectation is the for flag - SOAP_XML_DEFAULTNS, the xsi:type should return "CanonicalUser", rather it returns "s3:CanonicalUser". Is there any way we can preserve behavior of the older version?
The old code was changed/removed after 2.8.17 because it triggered a bug with the
SOAP_XML_DEFAULT
flag. The code is insufficient. Note thatxsi:type
is only useful for cases that require inheritance, i.e. to distinguish the base from a derived type. Newer gsoap versiosn do not usexsi:type
by default any longer, only to disambiguate base/derived types.Let me explain why the old code fails. Consider:
without prefixes this should be:
It is not correct to remove the prefix from the
xsi:type
, but only when the prefix matches the current default namespace of course. Now, normally we don't see anyxsi:type
attributes like this any longer.A better solution might be to make the following change to
soap_element()
:Upcoming gsoap 2.8.127 has the code update suggested above.