gpt4 book ai didi

web-services - gSOAP 和一般 SOAP 问题

转载 作者:行者123 更新时间:2023-12-04 06:33:00 26 4
gpt4 key购买 nike

我正在使用 gSOAP 从 WSDL 文档创建 C++ 代码。问题是当我在我的 WSDL 文件上运行 wsdl2h 工具时,gSOAP 给了我错误。这些错误都与命名空间问题有关。例如
Warning: could not find element 'GetRPCMethods' type '"http://www.broadband-forum.org/cwmp/cwmp-1-2.xsd":GetRPCMethods' in schema urn:tr069
我在下面粘贴了命名空间定义和如何使用它们的示例。有谁知道我哪里出错了?

urn:tr069 应该是指当前文档。

<s0:definitions 
name="tr069"
xmlns:s0="http://schemas.xmlsoap.org/wsdl/"
xmlns:s1="urn:tr069"
xmlns:s2="http://schemas.xmlsoap.org/wsdl/soap/"
targetNamespace="urn:tr069">

<s0:types>

<xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="urn:tr069"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd1="http://www.broadband-forum.org/cwmp/cwmp-1-2.xsd"
targetNamespace="urn:tr069">

<xsd:import namespace="urn:dslforum-org:cwmp-1-2" schemaLocation="cwmp-1-2.xsd" />
<xsd:element name="GetRPCMethods" type="xsd1:GetRPCMethods" />
</xsd:schema>
</s0:types>
<s0:message name="GetRPCMethods">
<s0:part element="s1:GetRPCMethods" name="GetRPCMethods" />
</s0:message>
</s0:definitions>

我还有其他一些问题,据我所知,目标命名空间不必指向实际位置,它只是指向当前文档的约定,这是正确的吗?同样在 cwmp-1-2.xsd 中有一个名为 GetRPCMethods 的元素,它包含一个包含另一个元素的序列。最好的做法是使用整个元素(GetRPCMethods)作为消息的一部分,还是我应该在消息中定义 GetRPCMethods 的特定部分?

谢谢你。

最佳答案

问题在于 <schema> 中定义的元素标签。首先,我删除了 <schema> 中所有已定义的元素标签,因为无论如何它们都是完全没有必要的。然后我将消息部分中元素的命名空间从 s1 更改为 xsd1 以使用 cwmp-1-2.xsd 中的元素,而不是我在 <schema> 中定义的元素。标签。

至于我的其他问题,targetNameSpace 不必指向真正的 uri,它只是此文档命名空间的名称。对于我的第二个问题,我认为使用整个架构元素作为消息的一部分可能是最好和最简单的。

关于web-services - gSOAP 和一般 SOAP 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5156945/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com