【问题标题】:C++ gSOAP wsdl typesC++ gSOAP wsdl 类型
【发布时间】:2011-12-21 12:44:15
【问题描述】:

我正在处理一个 .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

【问题讨论】:

    标签: c++ soap wsdl gsoap


    【解决方案1】:

    我自己尝试编写了一些 WSDL 文件,但是我发现它们很难正确编写,主要是因为 XML 命名空间,所以我建议您使用 C++ 编写类并生成 WSDL 文件自动从他们那里得到,而不是反过来。

    如果这是不可能的,我建议看看这个thread。我认为如果您将架构更改为这样的内容,它可能会起作用:

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

    【讨论】:

    • 完美,非常感谢。是的,我真的应该开始使用生成的文件。我想如果我自己先做这样的事情,我会更好地理解 SOAP。
    • 不客气!我自己解决了你的问题,相信我,你自己编写 WSDL 文件可能真的很复杂......
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多