1

I have an XSD schema file using anyAttributes for allowing custom extensions for different users. Unfortunately, I am getting problems with the C++ code generated by gSOAP. It works fine for everything not being modeled as anyAttributes, but if there are anyAttributes used, they are ignored by the parsing result.

I wrote a simple example consisting of an xsd file that's the basis for my gsoap code generation, an xml file that I use to create a SOAP request and the c++ code to get the necessary information from my request.

I have the following xsd file:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           targetNamespace="http://www.test.de/mb/intf/testProject/remote"
           xmlns:test="http://www.test.de/mb/intf/testProject/remote"
           version="1.0"
           xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"
           vc:minVersion="1.1"
           elementFormDefault="qualified">
    <xs:element name="TestProjectRequest">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="testElement"
                            type="test:TestElement"
                            minOccurs="1"
                            maxOccurs="1"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:complexType name="TestElement">
        <xs:attribute name="someNormalContent"
                      type="xs:string"
                      use="required"/>
        <xs:anyAttribute/>
    </xs:complexType>
</xs:schema>


and the following xml input file:

<testProjectRequest xmlns='http://www.test.de/mb/intf/testProject/remote'>
    <testElement someNormalContent="someText"
                 myExtension="someMoreText"/>
</testProjectRequest>

I build the project with gsoap and parse the content with the following c++ code:

    // create a soap request
    soap_begin(soap);
    soap_set_mode(soap, SOAP_XML_GRAPH | SOAP_C_UTFSTRING);
    soap_set_namespaces(soap, ::namespaces);

    auto istream = getInputData();
    soap->is = istream.get();

    // deserialize the request
    _testProject__TestProjectRequest* request = nullptr;
    request = soap_new__testProject__TestProjectRequest(soap, -1);
    soap_read__testProject__TestProjectRequest(soap, request);

    auto testElement = request->testElement;

    auto attribute = testElement->someNormalContent;
    auto anyAttribute = testElement->__anyAttribute; // anyAttribute is never filled

I also tried some other variations of how to model the anyAttribute. The result was always the same (except that for some I did not even get the __anyAttribute member generated). Does someone see the error cause? I would really appreciate any help with this subject.

CJacker
  • 11
  • 3

0 Answers0