Search code examples
c++soapwsdlgsoap

C++ gSOAP wsdl types


I'm working on a .wsdl file to define a service for gSOAP. In one of the service's requests, I want to use a user defined type as part of the request, but I can't get it right, and don't know what the problem is:

<definitions name="Uploader"
    targetNamespace="http://192.168.2.113/uploader/uploader.wsdl"
    xmlns:tns="http://192.168.2.113/uploader/uploader.wsdl"
    [...]>
[...]
<types>
    <schema targetNamespace="http://192.168.2.113/uploader/uploader.wsdl"
        xmlns="http://www.w3.org/2001/XMLSchema">

        <element name="FileInformation">
            <complexType><all>
                <element name="sFilename" type="string"/>
                <element name="bDirectory" type="boolean"/>
            </all></complexType>
        </element>

        [...]

        <element name="UploadRequest">
            <complexType><all>
                <element name="fileInfo" type="tns:FileInformation"/>
            </all></complexType>
        </element>

        [...]

    </schema>
</types>
[...]
</definitions>

When I try to generate header files out of it with wsdl2h -o Uploader.h http://192.168.2.113/uploader/uploader.wsdl the fileInfo member will be defined as a string and I get the following warning:

Warning: could not find element 'fileInfo' type '"http://192.168.2.113/uploader/uploader.wsdl":FileInformation' in schema http://192.168.2.113/uploader/uploader.wsdl

Solution

  • I've tried to write a few WSDL files myself, however I discovered that they are very difficult to get right, mainly because of the XML namespaces, so I would recommend that you write your classes in C++ and generate the WSDL file automatically from them instead of doing it the other way around.

    If that is not possible I would suggest that take a look at this thread. I think that if you change your schema to something like this, it might work:

    <definitions name="Uploader"
    targetNamespace="http://192.168.2.113/uploader/uploader.wsdl"
    xmlns:tns="http://192.168.2.113/uploader/uploader.wsdl">
    
    <types>
        <schema targetNamespace="http://192.168.2.113/uploader/uploader.wsdl"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    
           <xsd:element name="FileInformation" type="tns:FileInformation" />
           <xsd:complexType name="FileInformation">
               <xsd:all>
                    <xsd:element name="sFilename" type="string"/>
                    <xsd:element name="bDirectory" type="boolean"/>
                </xsd:all>
           </xsd:complexType>
    
            <xsd:element name="UploadRequest" type="tns:UploadRequest"/>
            <xsd:complexType name="UploadRequest">
                <xsd:all>
                    <xsd:element name="fileInfo" type="tns:FileInformation"/>
                </xsd:all>
            </xsd:complexType>
    
       </schema>
    </types>
    </definitions>