gSOAP 和一般 SOAP 问题
我正在使用 gSOAP 从 WSDL 文档创建 C++ 代码。问题是当我在 WSDL 文件上运行 wsdl2h 工具时,gSOAP 给出错误。这些错误都与命名空间问题有关。例如
警告:在架构 urn:tr069 中找不到元素 'GetRPCMethods' 类型 '"http://www.broadband-forum.org/cwmp/cwmp-1-2.xsd":GetRPCMethods'
我在下面粘贴了命名空间定义和如何使用它们的示例。有人知道我哪里出错了吗?
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 的特定部分?
谢谢。
I am using gSOAP to create C++ code from a WSDL document. The problem is gSOAP is giving me errors when I run the wsdl2h tool on my WSDL file. The errors are all related to namespace issues. For example
Warning: could not find element 'GetRPCMethods' type '"http://www.broadband-forum.org/cwmp/cwmp-1-2.xsd":GetRPCMethods' in schema urn:tr069
I have pasted the namespace definitions and an example of how they are used below. Anyone know where I am going wrong?
urn:tr069 is supposed to refer to the current document.
<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>
I have a few other questions, as I understand it the target namespace does not have to point to a real location, it is just a convention for pointing to the current document, Is this correct? Also in cwmp-1-2.xsd there is an element called GetRPCMethods which contains a sequence containing another element. Is it best practice to use this whole element(GetRPCMethods) as a part for a message as I have above or should I define the specific parts of GetRPCMethods in the message?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
问题在于
标记中定义的元素。首先,我删除了
标记内所有定义的元素,因为无论如何它们都是完全不必要的。然后,我将消息部分中元素的命名空间从 s1 更改为 xsd1,以使用 cwmp-1-2.xsd 中的元素,而不是我在
标记中定义的元素。至于我的其他问题,targetNameSpace 不必指向真正的 uri,它只是此文档的命名空间的名称。对于我的第二个问题,我认为使用整个架构元素作为消息的一部分可能是最好也是最简单的。
The problem was the elements defined in the
<schema>
tag. First I removed all the defined elements inside the<schema>
tag because they were completely unnecessary anyway. Then I changed the namespace of the elements in the message parts from s1 to xsd1 to use the elements in cwmp-1-2.xsd instead of the ones I defined in the<schema>
tag.As for my other questions, the targetNameSpace does not have to point to a real uri, it is just a name for the namespace of this document. For my second question, I think it is probably best and easiest to use the whole schema element as the part for the message.
我注意到
没有结束标记? wsdl 是格式良好的 XML 文档吗?
Targetnamespace 是实例文档的命名空间,即 SOAP:Envelope 的命名空间。
I notice that
doesn't have a closing tag? Is the wsdl a well-formed XML Document?
Targetnamespace is the namespace of the instance document ie., the one for SOAP:Envelope.
错误消息表明出了什么问题,您没有 xsd1:GetRPCMethods 的定义,这是在某处定义的吗?
s1:GetRPCMethods 被查找 ->发现s1是urn:trn069-> urn:trn069 不是唯一的,这可能是一个问题 -> urn:trn69 定义元素 GetRPCMethods,其类型为 xsd1:GetRPCMethods ->未找到此类型。
我不确定对 targetNamespace 使用相同的 URI 是否有效。也许这会导致额外的问题。
The error message says what's wrong, you don't have a definition of xsd1:GetRPCMethods, is this somewhere defined?
s1:GetRPCMethods is looked up -> s1 is found to be urn:trn069 -> urn:trn069 is not unique which might be a problem -> urn:trn69 defines the element, GetRPCMethods which is of type xsd1:GetRPCMethods -> this type is not found.
I'm not sure if it is valid to use the same URI for the targetNamespace. Maybe that's causing additional problems.