C++ gSOAP wsdl types

C++ gSOAP wsdl types

本文关键字:types wsdl gSOAP C++      更新时间:2023-10-16

我正在处理一个.wsdl文件,为gSOAP定义一个服务。在一个服务请求中,我想使用用户定义的类型作为请求的一部分,但是我不能正确使用,并且不知道问题是什么:

<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>

当我尝试用wsdl2h -o Uploader.h http://192.168.2.113/uploader/uploader.wsdl生成头文件时,fileInfo成员将被定义为字符串,我得到以下警告:

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

我曾尝试自己编写一些WSDL文件,但是我发现它们很难正确编写,主要是因为XML名称空间,所以我建议您使用c++编写类,并从它们自动生成WSDL文件,而不是使用其他方法。

如果这是不可能的,我建议看看这个线程。我想如果你把你的模式改成这样,它可能会起作用:

<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>