我正在使用 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 的特定部分?
谢谢你。