Hi there,

I have a problem with XML-deserializing. I've got a XML schema which I
used to generate the header file.

File Configuration.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
elementFormDefault="qualified" attributeFormDefault="unqualified">
     <xs:element name="Books">
         <xs:complexType>
             <xs:sequence>
                 <xs:element name="Book" type="xs:string"/>
             </xs:sequence>
         </xs:complexType>
     </xs:element>
</xs:schema>

I generated the header file:
wsdl2h -s -o Configuration.h Configuration.xsd

File Configuration.h
//  Forward declaration of class _ns1__Books.
class _ns1__Books;


/// Element "":Books of complexType.

/// "":Books is a complexType.
class _ns1__Books
{ public:
/// Element Book of type xs:string.
     char*                                Book                          
1;    ///< Required element.
/// A handle to the soap struct that manages this instance
(automatically set)
     struct soap                         *soap                          ;
};

And finally i wrote a client to de-serialize the XML message:
The message is as below:
<?xml version="1.0" encoding="UTF-8"?>
<xs:ken xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:xs="http://www.w3.org/2001/XMLSchema";
xmlns:ns1="http://www.w3.org/2001/XMLSchema";
xmlns:_ns1="http://www.w3.org/2001/XMLSchema";><xs:Book>12345</xs:Book></\
xs:ken>

Part of the client code:
void readxml() {
    struct soap soap;
    _ns1__Books book;
    book.soap = &soap;

    soap_init(&soap);
    soap_imode(&soap, SOAP_ENC_ZLIB); // optional: gzip is detected
automatically
    soap_begin(&soap);
    soap_begin_recv(&soap);
    if (book.soap_get(&soap, "ken", "") == NULL) {
        std::cout << "De-serializing failed...\n";
        exit(1);
    }
    std::cout << book.Book << std::endl;
    soap_end_recv(&soap);
    soap_free_temp(&soap); // Clean up temporary data but keep
deserialized data
    soap_destroy(&soap);
    soap_end(&soap);
    soap_done(&soap);
}
...
struct Namespace namespaces[] =
{
    {"xsi", "http://www.w3.org/2001/XMLSchema-instance"},
    {"xsd", "http://www.w3.org/2001/XMLSchema"},
    {"xs" , "http://www.w3.org/2001/XMLSchema"},
    {"ns1" , "http://www.w3.org/2001/XMLSchema"},
    {"_ns1" , "http://www.w3.org/2001/XMLSchema"},
    {NULL, NULL}
};

When I ran : ./a.out < msg.xml

The program finished, without error message but it also does not print
out the message either. In debugger, it shows the Book value as NULL
pointer.

Any idea why ?

Thanks,
Ken

Reply via email to